在Linux中执行文件操作时如何排除文件夹,例如cp,mv,rm和chown等(How do I exclude a folder when performing file operations i.

编程入门 行业动态 更新时间:2024-10-24 04:31:58
在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.

更多推荐

本文发布于:2023-08-06 19:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1454995.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   执行文件   操作   mv   cp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!