MEPX
Chapter 6 of 10All chapters

Chapter 6 of 10

Searching

Finding files and finding text.

Two different jobs

find locates files by name, size, age or type anywhere under a directory. grep searches inside files for lines matching a pattern.

  • find . -name "*.log" lists log files below the current directory.
  • grep -r "timeout" . searches every file underneath, and -i ignores case.

Combining them

find with -exec runs a command on each result, and xargs does the same from a pipe. That pairing is how bulk renames and cleanups get done.