What does sed do?
sed is a stream editor: most often used to find and replace text, e.g. sed 's/old/new/g' file.
sed [-i] 's/find/replace/g' [file]
Most useful options
| Option | What it does |
|---|---|
| s/a/b/ | replace the first a with b on each line |
| g | replace all on the line |
| -i | edit the file in place |
| -n 5p | print only line 5 |
sed examples
In security work
Admins harden config files with sed in scripts; always back up before sed -i.
Questions about sed
How do I replace text in a file in Linux?
sed -i 's/old/new/g' file