在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)
如何在执行文件操作时排除文件夹,例如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.
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.
更多推荐
发布评论