正则表达式,从查找中排除文件类型 [英] regular expression to exclude filetypes from find
本文介绍了正则表达式,从查找中排除文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Linux中使用find
命令时,可以添加一个使用emacs regualr表达式进行匹配的-regex
标志.
When using find
command in linux, one can add a -regex
flag that uses emacs regualr expressions to match.
我想查找除.jar
文件和.ear
文件之外的所有文件.在这种情况下,正则表达式是什么?
I want find to look for all files except .jar
files and .ear
files. what would be the regular expression in this case?
谢谢
推荐答案
此处不需要正则表达式.您可以将find
与-name
和-not
选项一起使用:
You don't need a regex here. You can use find
with the -name
and -not
options:
find . -not -name "*.jar" -not -name "*.ear"
上述内容的一个更简洁(但可读性更差)的版本是:
A more concise (but less readable) version of the above is:
find . ! \( -name "*.jar" -o -name "*.ear" \)
这篇关于正则表达式,从查找中排除文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文