Cheat Sheet
The commands you keep forgetting, with a one-line description and a real example you can copy - 629 across 38 tools. Pick a tool in the sidebar, or search across all of them.
sed
Stream-edit text - find and replace, delete lines, and rewrite files in place.| Command | What it does | Example |
|---|---|---|
sed substitute | Replace the first match on each line. | sed 's/foo/bar/' notes.txt |
sed global | Replace every match on each line. | sed 's/http:/https:/g' links.txt |
sed -i | Edit the file in place instead of printing. | sed -i 's/localhost/127.0.0.1/g' config.yml |
sed -i.bak | Edit in place, keeping a backup of the original. | sed -i.bak 's/debug: true/debug: false/' app.yml |
sed delete | Delete matching lines (here: comments). | sed '/^#/d' nginx.conf |
sed delete blanks | Strip empty lines from a file. | sed '/^$/d' notes.txt |
sed -n p | Print only a line range. | sed -n '10,20p' app.log |
sed (line target) | Substitute only on one line number. | sed '3s/false/true/' config.yml |
sed (match target) | Substitute only on lines matching a pattern. | sed '/^port/s/8080/3000/' server.conf |
sed -E | Extended regex: +, ?, | without backslashes. | sed -E 's/[0-9]+ ms/fast/g' bench.txt |
sed capture groups | Rearrange text with \1 backreferences. | sed -E 's/(\w+)@example.com/\[email protected]/' emails.txt |
sed | delimiter | Use another delimiter so paths need no escaping. | sed 's|/var/www|/srv/www|g' deploy.sh |
sed insert line | Insert a line before a target (here: line 1). | sed '1i #!/bin/bash' run.sh |
sed append line | Append a line after a matching line. | sed '/^\[api\]/a timeout = 30' config.ini |
sed -e (chain) | Run several edits in one pass. | sed -e 's/http:/https:/g' -e '/^#/d' urls.txt |
sed $ (last line) | $ addresses the last line (here: delete it). | sed '$d' trailing.txt |