Over time you will accumulate a large number of files that will be stored in various directories. To make the task of locating these files easier Linux comes with the find command to search for and display file names that match a specific text string.

Tip: If you are not the Superuser, you may receive permission denied error messages on certain files and/or directories. The file you are searching for will only be matched if you have search permission on the directory that contains the file for which you are searching.

Command Format

find pathname expression

Example

The following command searches your current directory and all of its subdirectories, and then it displays file names of any length that end in the letter s:

$ find . -name '*s'
.
/brands
./Snoopy/Cool _dogs
./Snoopy/dog_houses
./Snoopy/feathers
./Snoopy/compositions/notes
./Woodstock/Heros
./Woodstock/Flights
./Woodstock/Flight/Heros
./Pig_Pen/puddle
./Pig_Pen/Dirt/notes
./Pig_Pen/Dirt /mud_puddles
./Pig_Pen/puddles
./Franklin/Baseballs
./Franklin/books
./Play/Game/bats
./Game/fields
./Game/bats/fields