How do I find all files that do not begin with a given prefix in bash?

前端 未结 6 2064
旧时难觅i
旧时难觅i 2020-12-19 12:42

I have a bunch of files in a folder:

foo_1 
foo_2
foo_3
bar_1
bar_2
buzz_1
...

I want to find all the files that do not st

6条回答
  •  执念已碎
    2020-12-19 13:17

    If you're doing subdirectories as well:

    find . ! -name "bar_*"
    

    Or, equivalently,

    find . -not -name "*bar_*"
    

提交回复
热议问题