Skip to content

sed

  • Replace foo with bar in a file :)
Bash
 sed -i 's/foo/bar/g' /some/path/file.txt

Replace "dark" or "somecrap" or "light" to "boles"

Bash
 sed -i 's/dark/boles/g;s/somecrap/boles/g;s/light/boles/g' /some/path/file.txt
  • Delete line using matching patterns in a line
Bash
sed -i '/pattern-to-match/d' ./some/file
  • Mach based on part of a pattern
Bash
sed -i '/backend=/c\  export backend=soemthing' somefile
Back to top