Linux & Open Source » Shell Command: Find


Find recursively searches a location for files or directories. It has many flags to output only the files that you are looking for. This can then be combined with other commands to produce a very customised output of exactly what you are looking for.

find / -name "test*"
Searches the root filesystem for a file or directly that starts with test.
find . -type f -printf '%TY-%Tm-%Td\t%TH:%TM:%.2TS\t%P\n' \
| sort -n \
| cut -f3
Searches the current directory and shows the most recently modified files last.
find . -type f -size 2M -printf "%P\t" -exec file -ib {} \; \
| grep "image/" \
| cut -f 1
Searches for all image files over 2 Megabytes in the current directory.
find . -size 2M -iname '*.png' -o -size 2M -iname '*.jpg' -o -size 2M -iname '*.gif'
Another way to search for images over 2M would be like this but it will only return png, jpg and gif files. Other image formats like bmp and images called something.jpeg would not show.
find . -regex '^.20[0-9][0-9]-07-10-[A-Z][a-z][a-z]-\(0[8-9]\|[1][0-7]\)-[0-9][0-9]-[0-9][0-9]\.jpg'
Searches using a regular expression and will return jpeg images from July 10th between 8:00 am and 5:59 pm when the filenames are formatted like this "2001-07-10-Tue-17-55-01.jpg".