This topic created in 4885 days ago, the information mentioned may be changed or deeloped.
我常用cp命令复制文件和文件夹都会遇到的问题,比如:
/example
|--/a
|--/b
|--/c
|--/d
|--/e.txt
……(假设此目录有上千个文件)
/example2
|--/f
我想用拷贝exmaple目录下所有的子目录和文件到example2可以用:
cp -rf /exmaple/* /example2
但如果我不想拷贝其中的/exmaple/d/ 这个子目录到 /example2,要怎么做?
10 replies 1970-01-01 08:00:00 +08:00  | | 1 Js Dec 27, 2012 1 cp -rf /exmaple/!(d) /example2 |
 | | 2 lusin Dec 27, 2012 拷过去再把/d删除掉 |
 | | 4 napoleonu Dec 27, 2012 cd /exmaple/ ; ls | grep -v 'd' | xargs -n1 -i cp -rf {} /example2 |
 | | 5 plprapper Dec 27, 2012 压缩打包的时候是有exclution之类的参数排除掉 一些文件或者目录的 先把拷贝的包。。压缩一个排调不要的 然后再解压。。。放好 。
哈哈 这是我的第一反应 cp 没注意有没有类似的参数 |
 | | 6 lululau Dec 27, 2012 如果这个目录下面有成千上万个文件,那你最好不要用通配符,可能会出现 argument list too long 的问题,建议使用find
find . -not -name filename -maxdepth 1 -exec cp -a {} /example2 \; |
 | | 9 terry Dec 28, 2012 这种情况肯定是用 rsync 然后 --exclude 不需要的目录(或者 --exclude-from 一个文本文件)这么干了,cp 太挫不靠谱。 |