cmdxray / commands / find

What does find do?

walk a directory tree looking for files.

▸ Explain your own find command →

find examples, explained

$ find . -name '*.log' -mtime +30 -delete

  • findwalk a directory tree looking for files
  • .an argument passed to the command
  • -namematch files by this name pattern
  • *.logvalue for -name
  • -mtimematch by modification age in days
  • +30value for -mtime
  • -deletedelete each matching file

$ find src -type f -maxdepth 2

  • findwalk a directory tree looking for files
  • srcan argument passed to the command
  • -typematch by type (f=file, d=directory, l=symlink)
  • fvalue for -type
  • -maxdepthdescend at most this many directory levels
  • 2value for -maxdepth

find flags & options

-namematch files by this name pattern
-inamematch by name, case-insensitively
-pathmatch by path pattern
-ipathmatch by path pattern, case-insensitively
-typematch by type (f=file, d=directory, l=symlink)
-mtimematch by modification age in days
-mminmatch by modification age in minutes
-sizematch by file size
-newermatch files newer than the given reference file
-usermatch files owned by this user
-groupmatch files owned by this group
-permmatch files with these permission bits
-emptymatch empty files and directories
-execrun a command on each match ({} = the file, ; ends it)
-execdirlike -exec, but run from the match's own directory
-oklike -exec, but prompt before running each command
-okdirlike -execdir, but prompt before running each command
-deletedelete each matching file
-prunedon't descend into a matching directory
-maxdepthdescend at most this many directory levels
-mindepthignore matches shallower than this many levels
-printprint each match (the default action)
-print0print each match separated by NUL (for xargs -0)

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.