community man page
sed
Edit text in a scriptable manner. See also: `awk`, `ed`.
Examples
substitute all occurrences of "apple" with "mango" on all lines, print to `stdout` GNU
Replace "apple" with "mango" in-place in a file (overwriting original file) GNU
Run multiple substitutions in one command GNU
Use a custom delimiter (useful when the pattern contains slashes) GNU
delete lines 1 to 5 of a file and back up the original file with a `.orig` extension GNU
print only the first line to `stdout` GNU
insert a new line at the beginning of a file, overwriting the original file GNU
Delete blank lines (with or without spaces/tabs) from a file, overwriting the original file GNU
Replace all `apple` (basic `regex`) occurrences with `mango` (basic `regex`) in all input lines and print the result to `stdout`
Execute a specific script file and print the result to `stdout`
Print just a first line to `stdout`
Recipes
⚠ destructiveadvancedGNU
Replace every occurrence of localhost with 127.0.0.1 in config.ini, editing the file in place. `-i.bak` writes the edit in place but first saves the original as config.ini.bak. DESTRUCTIVE: `-i` rewrites the file; the `.bak` suffix is your undo path (plain `-i` with no suffix leaves no backup).