Searching for a file by name or extension
suggest changeTo 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents