如何查找除名字以外的文件? [英] How to find files except given name?
问题描述
我有一个dir:
- bla-bla-bla1.tar.7z
- bla-bla-bla2.tar.7z
- bla-bla-bla3.tar.7z
- _bla-bla-bla_foo.tar.7z
除了_ .7z之外,我需要找到并删除所有 .7z p> 我使用find / backups / -name* .7z-type f -mtime +180 -delete 如何才能做到这一点? 另一种方法是使用 这个简单的正则表达式其他答案更适合您的用例,但是这显示了使用 I have a dir with: I need to find and delete all files ".7z" except "_.7z" I use find /backups/ -name "*.7z" -type f -mtime +180 -delete How i can do it? Another approach is to use an additional, negated primary with The simple regex in the other answers is better for your use case, but this demonstrates a more general approach using the 这篇关于如何查找除名字以外的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
find
:
find / backups / -name* .7z! -name'_.7z'-type f -mtime +180 -delete
find >找到的
!
运算符的更一般的方法。
find
: find /backups/ -name "*.7z" ! -name '_.7z' -type f -mtime +180 -delete
!
operator available to find
.