Linux grep and find

Find files by name, age, and size; search inside them fast.

  • linux find
  • grep recursive
  • find mtime
  • xargs
  • search files

Linux grep and find

Find files by name, age, and size; search inside them fast.

Commands

CommandWhat it does
find . -name patternFiles by glob
find . -mtime -7 -type fModified in last 7 days
find . -size +100MLarger than 100 MB
grep -rn TODO src/Recursive content search
grep -rl secret, exclude gitFile names only, skip VCS

Example

find . -type f -name '*.log' -mtime +30 -print
grep -rn 'FIXME' src/ | head

FAQ

Is find -delete safe?

Always run with -print first, then swap to -delete - there is no trash recovery.

Spaces in filenames break xargs?

Use -print0 with xargs -0, or -exec with plus for batching.

Perguntas frequentes

Is find -delete safe?
Always run with -print first, then swap to -delete - there is no trash recovery.
Spaces in filenames break xargs?
Use -print0 with xargs -0, or -exec with plus for batching.

Linux