What is the Linux equivalent of DOS "dir /s /b filename"?

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.


Some shells allow ls **/filename, which is quite convenient.


You can do this with

find . | egrep filename

Tags:

Ls