↑↓ move Enter open Esc close

Cheat sheet · 13 commands

Search

grep searches inside files, find searches for the files themselves. Together they answer nearly every "where is it?" question on a machine, and they combine, since find can run grep on whatever it finds.

The 3 you will use every day

Recursive, with file names and line numbers

Find by name (quote the pattern!)

Files larger than 100 MB

The full sheet

  • Lines containing "text"guide ›
  • Case-insensitiveguide ›
  • Lines that do NOT contain itguide ›
  • Recursive, with file names and line numbersguide ›
  • Count matching lines instead of printing themguide ›
  • 2 lines before and 5 after each matchguide ›
  • Only the names of files that matchguide ›
  • Find by name (quote the pattern!)guide ›
  • Find directories by nameguide ›
  • Files larger than 100 MBguide ›
  • Modified in the last 24 hoursguide ›
  • Delete matches (run it once without -delete first)guide ›
  • Run a command on every matchguide ›
Practise these for real in the interactive course, or keep every sheet, chapter and fix in one book: The Linux Command Line Handbook.