Index

find

searching

find files
find . -type f
find directories
find . -type d
find files or directories with the given name
find . -name "target"
find files modified in the last 90 days
find . -type f -mtime -90
find files modified exactly 90 days ago
find . -type f mtime 90
find files modified at least 90 days ago
find . -type f +mtime 90

deleting

delete empty files
find /path/to/dir -empty -type f -delete
delete empty directories
find /path/to/dir -empty -type d -delete
delete all files matching a pattern
find . -type f -name "*.log" -delete
delete all directories and their contents matching a pattern(workaround for problem with -exec)
find ./ -name "target" | xargs rm -rf

exec

execute a statement for every file
find . -type f -exec ls -l {} \;
slightly more flexible method
for file in $(find . -type f); do echo "file $file"; done