List all files/dirs in or below the current directory that match ‘filename’.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The direct equivalent is
find . -iname <filename>
which will list all files and directories called <filename> in the current directory and any subdirectories, ignoring case.
If your version of find doesn’t support -iname, you can use -name instead. Note that unlike -iname, -name is case sensitive.
If you only want to list files called <filename>, and not directories, add -type f
find . -iname <filename> -type f
If you want to use wildcards, you need to put quotes around it, e.g.
find . -iname "*.txt" -type f
otherwise the shell will expand it.
As others have pointed out, you can also do:
find . | grep ".txt$"
grep will print lines based on regular expressions, which are more powerful than wildcards, but have a different syntax.
See man find and man grep for more details.
Method 2
Some shells allow ls **/filename, which is quite convenient.
Method 3
You can do this with
find . | egrep filename
Method 4
It can be also: tree -if </your/path> or 'pwd' as a path
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0