复制除test文件夹中出了名为test2文件夹外的所有文件到copy_test文件夹:
# 进入test文件夹
cp `ls |grep -v test2|xargs` ../copy_test
# 在test文件夹之外
cp `ls /home/wy/test |grep -v test2|xargs` /home/wy/copy_test
该操作进入test文件夹,使用ls命令过滤出非test2的文件,通过grep和xargs配合cp命令将其复制到../copy_test。在文件夹外部,同样方法将/home/wy/test中的相应内容复制到/home/wy/copy_test。
复制除test文件夹中出了名为test2文件夹外的所有文件到copy_test文件夹:
# 进入test文件夹
cp `ls |grep -v test2|xargs` ../copy_test
# 在test文件夹之外
cp `ls /home/wy/test |grep -v test2|xargs` /home/wy/copy_test
2762
1万+
608
17

被折叠的 条评论
为什么被折叠?