用cp命令复制隐藏文件

场景:
做一个项目模板,如下:
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.blogjava.net/zhyiwww/,如需转载请自行联系原博主。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值