sed — Edit text in a scriptable manner. See also: `awk`, `ed`. # source: tldr · verified Examples: # substitute all occurrences of "apple" with "mango" on all lines, print to `stdout` [GNU] $ command | sed 's/apple/mango/g' # Replace "apple" with "mango" in-place in a file (overwriting original file) [GNU] $ sed [-i|--in-place] 's/apple/mango/g' path/to/file # Run multiple substitutions in one command [GNU] $ command | sed -e 's/apple/mango/g' -e 's/orange/lime/g' Advanced recipes: ⚠ $ sed -i.bak 's/localhost/127.0.0.1/g' config.ini # 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). [advanced] # ✎ Wrong or incomplete? Improve this page → https://curlhub.sh/man/sed