How to find files except given name?

前端 未结 4 1391
-上瘾入骨i
-上瘾入骨i 2021-02-13 01:50

There is a directory containing the following files:

.
├── bla-bla-bla1.tar.7z
├── bla-bla-bla2.tar.7z
├── bla-bla-bla3.tar.7z
└── _bla-bla-bla_foo.tar.7z
         


        
4条回答
  •  -上瘾入骨i
    2021-02-13 02:20

    A quick way given you have bash 4.2.25, is to simply use bash pattern matching to remove all .7z, but the ones having _.7z, like this:

    touch a.7z b.7z c.7z d_.7z e_.7z f.txt
    rm *[^_].7z
    

提交回复
热议问题