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 閱讀(3515) 評論(1)  編輯  收藏

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

          直接 cp -r templates/ templates.new

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

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


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 东明县| 乾安县| 卓尼县| 滦南县| 望谟县| 庄浪县| 介休市| 南靖县| 都昌县| 开平市| 勐海县| 萨嘎县| 甘泉县| 张家界市| 莱西市| 方山县| 赤水市| 普兰店市| 酉阳| 义马市| 洛阳市| 尖扎县| 岱山县| 武冈市| 斗六市| 泰兴市| 精河县| 吉林省| 荆州市| 桂东县| 泸西县| 潼关县| 深州市| 霍林郭勒市| 蓬溪县| 桂东县| 光泽县| 高尔夫| 金塔县| 应城市| 宝应县|