zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0

          場景:
          做一個項目模板,如下:
          test@andy-N61Vn:/tmp/xxx$ ll proj_template/
          total 28
          drwxrwxr-x 5 test test 4096 2012-07-10 11:46 ./
          drwxrwxr-x 3 test test 4096 2012-07-10 11:46 ../
          -rw-rw-r-- 1 test test  842 2012-07-10 11:46 .classpath
          -rw-rw-r-- 1 test test 1052 2012-07-10 11:46 .project
          drwxrwxr-x 2 test test 4096 2012-07-10 11:46 .settings/
          drwxrwxr-x 3 test test 4096 2012-07-10 11:46 src/
          drwxrwxr-x 5 test test 4096 2012-07-10 11:46 WebRoot/
          新建項目:
          從項目模板復制,用以下命令:
          test@andy-N61Vn:/tmp/xxx$ cp proj_template/ demo -rf

          就可以從模板項目創建一個新的項目。
          項目文件如下:
          test@andy-N61Vn:/tmp/xxx$ ll demo/
          total 28
          drwxrwxr-x 5 test test 4096 2012-07-10 11:48 ./
          drwxrwxr-x 4 test test 4096 2012-07-10 11:48 ../
          -rw-rw-r-- 1 test test  842 2012-07-10 11:48 .classpath
          -rw-rw-r-- 1 test test 1052 2012-07-10 11:48 .project
          drwxrwxr-x 2 test test 4096 2012-07-10 11:48 .settings/
          drwxrwxr-x 3 test test 4096 2012-07-10 11:48 src/
          drwxrwxr-x 5 test test 4096 2012-07-10 11:48 WebRoot/
          假如:
          我已經有了一個目錄,如proj2,里面沒有文件,如下:
          test@andy-N61Vn:/tmp/xxx$ ll proj2
          total 8
          drwxrwxr-x 2 test test 4096 2012-07-10 11:50 ./
          drwxrwxr-x 5 test test 4096 2012-07-10 11:50 ../
          再做文件復制:
          test@andy-N61Vn:/tmp/xxx$ cp proj_template/* proj2/ -rf
          test@andy-N61Vn:/tmp/xxx$ ll proj2/
          total 16
          drwxrwxr-x 4 test test 4096 2012-07-10 11:51 ./
          drwxrwxr-x 5 test test 4096 2012-07-10 11:50 ../
          drwxrwxr-x 3 test test 4096 2012-07-10 11:51 src/
          drwxrwxr-x 5 test test 4096 2012-07-10 11:51 WebRoot/
          我們可以發現,在模板項目中存在的隱藏文件.project .classes .
          .settings/并沒有復制過來。

          解決辦法:
          使用如下命令:
          test@andy-N61Vn:/tmp/xxx$ cp proj_template/.  proj2 -rf
          test@andy-N61Vn:/tmp/xxx$ ll proj2/
          total 28
          drwxrwxr-x 5 test test 4096 2012-07-10 11:52 ./
          drwxrwxr-x 5 test test 4096 2012-07-10 11:50 ../
          -rw-rw-r-- 1 test test  842 2012-07-10 11:52 .classpath
          -rw-rw-r-- 1 test test 1052 2012-07-10 11:52 .project
          drwxrwxr-x 2 test test 4096 2012-07-10 11:52 .settings/
          drwxrwxr-x 3 test test 4096 2012-07-10 11:51 src/
          drwxrwxr-x 5 test test 4096 2012-07-10 11:51 WebRoot/

          上面的命令可以實現連同隱藏文件一同復制。
          注意:
          命令的關鍵地方,也就是紅色字體的地方。





          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2012-07-10 11:52 zhyiwww 閱讀(3523) 評論(1)  編輯  收藏

          FeedBack:
          # re: 用cp命令復制隱藏文件
          2013-06-05 12:20 | 啊啊啊
          當用cp的時候 想要復制隱藏的文件一起走
          不要 cp -r ./templates/* ./templates.new

          直接 cp -r templates/ templates.new

          使用后面的方法就可以復制隱藏文件或者文件夾一起走了   回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 青海省| 怀化市| 松潘县| 温泉县| 扶风县| 永修县| 祁连县| 东至县| 衡南县| 玛纳斯县| 望谟县| 丹东市| 无极县| 泸西县| 蒲江县| 太湖县| 新河县| 绥江县| 横峰县| 东至县| 奉贤区| 南华县| 贡觉县| 泸州市| 霍山县| 深泽县| 临湘市| 平凉市| 双鸭山市| 繁昌县| 东光县| 洛宁县| 秀山| 怀宁县| 固镇县| 武胜县| 竹溪县| 布拖县| 桐乡市| 额济纳旗| 黑龙江省|