我有一个问题,在使用find命令的"-o"选项时,如何查找多个文件扩展名。
find "DIRECTORY" -type f -name \*.jpg -o -name \*.html -mtime +95
在上述情况下,我希望删除所有两种扩展名的文件,这些文件比某个特定时间旧。 通过使用
-o
列出多个名称,-mtime
是否仅适用于第二个名称,还是较旧的jpg也被排除在外?谢谢
find "DIRECTORY" -type f \( -name \*.jpg -o -name \*.html \) -mtime +95
find
操作符按照优先级顺序进行评估。来自手册:
( expr )
Force precedence. Since parentheses are special to the shell,
you will normally need to quote them. Many of the examples in
this manual page use backslashes for this purpose: `\(...\)'
instead of `(...)'.
expr1 expr2
Two expressions in a row are taken to be joined with an implied
"and"; expr2 is not evaluated if expr1 is false.
expr1 -o expr2
Or; expr2 is not evaluated if expr1 is true.
它只适用于第二个参数,我刚刚进行了手动检查
find "DIRECTORY" -type f \( -name \*.jpg -o -name \*.html \) -mtime +95
。 - ctrl-alt-delor