Useful Find Commands

# print list of all files in current 
# directory and sub-directories
find . -type f -print

# print list of all directories and 
# sub-directories in current directory
find . -type d -print

# search for a specific file 
# or directory name
find . -name "filename"

# search for a pattern, matching file 
# or directory names using a wildcard
find . -name "filename-*.txt"

# follow sym links as well
find . -follow -name "filename-*"

# find all files and folders 
# in current directory that 
# have been modified in 
# the past 1 day
find . -mtime 1

To act on the list of files found instead of simply listing them, try the -exec command.


# find all files in the current directory 
# and below and change permissions
find . -type f -exec chmod 644 {} \;

# find all folders in the current directory 
# and below and change permissions
find . -type d -exec chmod 755 {} \;

Find 10 largest files

find ./ -type f -exec du -Sh {} + | sort -rh | head -n 10
Snippets and tagged