在Linux中执行文件操作(即cp,mv,rm和chown等)时,如何排除文件夹 [英] How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux
本文介绍了在Linux中执行文件操作(即cp,mv,rm和chown等)时,如何排除文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
执行文件操作(例如cp等)时如何排除文件夹
How do you exclude a folder when performing file operations i.e. cp etc.
我目前将使用通配符*对所有文件应用文件操作,但是我需要排除一个文件夹.
I would currently use the wild card * to apply file operation to all, but I need to exclude one single folder.
我实际上想使用的命令是 chown
,以更改目录中所有文件的所有者,但是我需要排除一个子目录.
The command I'm actually wanting to use is chown
to change the owner of all the files in a directory but I need to exclude one sub directory.
推荐答案
如果您正在使用bash并通过 shopt -s extglob
启用extglob,则可以使用!(< pattern>)
排除给定的模式.
If you're using bash and enable extglob via shopt -s extglob
then you can use !(<pattern>)
to exclude the given pattern.
这篇关于在Linux中执行文件操作(即cp,mv,rm和chown等)时,如何排除文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文