Searching for a file by name or extension

suggest change

To find files/directories with a specific name, relative to pwd:

$ find . -name "myFile.txt"
./myFile.txt

To find files/directories with a specific extension, use a wildcard:

$ find . -name "*.txt"
./myFile.txt
./myFile2.txt

To find files/directories matching one of many extensions, use the or flag:

$ find . -name "*.txt" -o -name "*.sh"

To find files/directories which name begin with abc and end with one alpha character following a one digit:

$ find . -name "abc[a-z][0-9]"

To find all files/directories located in a specific directory

$ find /opt

To search for files only (not directories), use -type f:

find /opt -type f

To search for directories only (not regular files), use -type d:

find /opt -type d

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents