Find all files with a filename beginning with a specified string?

后端 未结 3 1178
忘了有多久
忘了有多久 2020-12-22 18:36

I have a directory with roughly 100000 files in it, and I want to perform some function on all files beginning with a specified string, which may match tens of thousands of

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 19:27

    ls | grep "^abc"  
    

    will give you all files beginning (which is what the OP specifically required) with the substringabc.
    It operates only on the current directory whereas find operates recursively into sub folders.

    To use find for only files starting with your string try

    find . -name 'abc'*

提交回复
热议问题