description find Overview
The find utility is the definitive tool for locating files and directories based on complex criteria like modification time, owner, size, or name pattern. While `ls` shows what's there now, `find` allows you to execute actions (like `rm` or `chmod`) on groups of files matching specific criteria across the entire filesystem, making it vital for system maintenance and cleanup scripts.
help find FAQ
How can I use find to locate only PDF files under a directory?
A common GNU find command is `find . -type f -iname '*.pdf'`, which searches from the current directory and matches regular files case-insensitively. The `-type f` condition prevents directories with a `.pdf` suffix from appearing in the results.
What does `find -mtime +90` actually mean?
In GNU find, `-mtime +90` selects files whose whole-day age is greater than 90 days, based on modification time. It is different from `-mtime -90`, which selects files modified within the last 90 whole days.
Why is `find -print0` safer than piping find output to xargs?
`-print0` separates pathnames with null characters, so spaces, quotes, and newlines inside filenames are preserved. It is normally paired with `xargs -0`, for example `find . -type f -print0 | xargs -0 ...`.
How can find run a command on every matching file?
The `-exec` action passes each matching pathname to another command, as in `find . -type f -name '*.log' -exec gzip {} \;`. GNU find also supports `-exec ... {} +`, which batches multiple matching files into fewer command launches.
explore Explore More
Similar to find
ui.x_see_all arrow_forwardReviews & Comments
Write a Review
Be the first to review
Share your thoughts with the community and help others make better decisions.