↑↓ move Enter open Esc close

Cheat sheet · 15 commands

Text processing

The filters that sit in the middle of pipelines. awk picks columns and does sums, sed edits streams, cut slices fields, sort and uniq count things. Learn one line of each and you can answer most log questions without a script.

The 3 you will use every day

Print the second column of any output

Replace every occurrence (prints the result)

Count occurrences of each line

The full sheet

  • Print the second column of any outputguide ›
  • Third column of a comma-separated fileguide ›
  • Sum a columnguide ›
  • Deduplicate, preserving original orderguide ›
  • Replace every occurrence (prints the result)guide ›
  • Replace in place, keeping a .bak backupguide ›
  • Print only lines 20 to 40guide ›
  • Strip comment linesguide ›
  • Extract columns 1 and 3guide ›
  • Sort lines alphabetically
  • Sort numerically, descending
  • Count occurrences of each lineguide ›
  • Show only the duplicated linesguide ›
  • Uppercase everythingguide ›
  • Strip Windows carriage returnsguide ›
Practise these for real in the interactive course, or keep every sheet, chapter and fix in one book: The Linux Command Line Handbook.