本文介绍了BASH 复制除一个以外的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从一个目录中复制所有文件,除了一个名为 Default.png 的文件.似乎有很多方法可以做到这一点.你觉得什么最有效?
I would like to copy all files out of a dir except for one named Default.png. It seems that there are a number of ways to do this. What seems the most effective to you?
推荐答案
简单,如果 src/
只包含文件:
Simple, if src/
only contains files:
find src/ ! -name Default.png -exec cp -t dest/ {} +
如果 src/
有子目录,则忽略它们,但会复制其中的文件:
If src/
has sub-directories, this omits them, but does copy files inside of them:
find src/ -type f ! -name Default.png -exec cp -t dest/ {} +
如果 src/
有子目录,这不会递归到它们:
If src/
has sub-directories, this does not recurse into them:
find src/ -type f -maxdepth 1 ! -name Default.png -exec cp -t dest/ {} +
这篇关于BASH 复制除一个以外的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!