BASH 复制除一个之外的所有文件 [英] BASH copy all files except one

查看:20
本文介绍了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 复制除一个之外的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆