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

后端 未结 3 1179
忘了有多久
忘了有多久 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:26

    If you want to restrict your search only to files you should consider to use -type f in your search

    try to use also -iname for case-insensitive search

    Example:

    find /path -iname 'yourstring*' -type f
    

    You could also perform some operations on results without pipe sign or xargs

    Example:

    Search for files and show their size in MB

    find /path -iname 'yourstring*' -type f -exec du -sm {} \;
    

提交回复
热议问题