Find a File in a Directory Using Unix Command

07-24-2020


If you’ve ever needed to find a file in a directory or subdirectory without clicking around this handy terminal command might help you find the file(s) more quickly.

The find command will search directories based on a name or pattern supplied.

Example

1
find /path/to/dir -name "my-missing-file" -print

Let’s break this down:

Command Purpose
/path/to/dir The path (relative or absolute) path to begin searching
-name The name flag will search all files in all directories for a match to the pattern
“my-missing-file” The pattern of the filename to match, could be something like: *.jpg
-print Will print the path for the matching files