Tech/Basics/Find
Jump to navigation
Jump to search
Searching filesystems with the find tool is something that all users will have to do some day.
Manual Page
Get used to looking at the manual page as there are a huge amount of options. Note that find on different OS will work differently even within OS so note the mentions of GNU extensions
Examples
List Files
List all the MP4 files in the current directory and near sub directories without prefixing the directory.
find . -type f -regex .*mp4 -printf "%f\n" | sort
- Look here and subdirectories up to the default depth
- Look for files
- Look for files ending in mp4
- Print the filename and a newline
- Sort the output as find uses the order the filesystem gives it.