Linux 使用find命令删除多个早于确定时间的扩展名
我在使用find中的“-o”选项查找多个扩展时遇到了一个问题Linux 使用find命令删除多个早于确定时间的扩展名,linux,shell,find,Linux,Shell,Find,我在使用find中的“-o”选项查找多个扩展时遇到了一个问题 find "DIRECTORY" -type f -name \*.jpg -o -name \*.html -mtime +95 在上面的例子中,我想删除超过一定时间的两个扩展名的所有文件。 通过使用-o列出多个名称,-mtime是否仅适用于第二个名称,还是也排除了较旧的JPG 谢谢它只适用于第二个参数,只是手动快速检查了一下你可以用括号解决这个问题: find "DIRECTORY" -type f \( -name \*.jp
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.
不知道,用括号括起来,否则无论哪种方式都可以,
找到“目录”-键入f\(-name\*.jpg-o-name\*.html\)-mtime+95