Cheat Sheet
The commands you keep forgetting, with a one-line description and a real example you can copy - 384 across 26 tools. Pick a tool in the sidebar, or search across all of them.
sed & awk
Stream-edit text (sed) and process columns (awk) on the command line.| Command | What it does | Example |
|---|---|---|
sed substitute | Replace the first match per line. | sed 's/foo/bar/' file.txt |
sed global | Replace every match on each line. | sed 's/foo/bar/g' file.txt |
sed -i | Edit the file in place. | sed -i 's/localhost/127.0.0.1/g' config.yml |
sed delete | Delete matching lines. | sed '/^#/d' config |
sed -n p | Print a line range. | sed -n '10,20p' file.txt |
awk print column | Print a field (1-indexed). | awk '{print $2}' data.txt |
awk -F | Set the field separator. | awk -F, '{print $1}' data.csv |
awk filter | Print rows matching a condition. | awk '$3 > 100' sales.txt |
awk sum | Sum a column. | awk '{s += $1} END {print s}' nums.txt |
awk NR | Use the line number (NR). | awk 'NR == 1' file.txt |
awk with text | Mix fields with literal text. | awk '{print "id:", $1}' users.txt |