Search for files in a directory hierarchy
command: find
package: GNU findutils
description: find – a powerful and flexible command to search for files in a directory hierarchy
# search files in current directory containing string "mp3"
find . -name "*mp3*"
# search for file name and directory name containing "file" and print content to stdout
find . -name "*file*" -print -exec cat {} \;
# count files recursively in current directory
find . -type f -printВ |wc -l
# list files and directories with status changed last 10 minutes
find . -cmin -10
# list files that have been modified on your system in the past 60 minutes
find / -mmin 60 -type f
# list files over 1k, direct to xargs and print a sorted list with ls
find . -size +1k -type f -print | xargs ls -Sshl
# only dig down 2 levels of directories below the command line, useful when on top of a deep directory hierarchy
find . -size +1k -type f -print | xargs ls -Sshl
Read "man find" for more syntax
October 4, 2009
Tags: find, linux Posted in: linux

Leave a Reply