Sed NotesPublished on 29 July, 2020 by Amanda
Replace text in file
sed -i '/pattern to match/new string' ./infileExample:
$ sed -i 's/\/home\/amanda/'\$'HOME/g' ./Baldurs-Gate-Enhanced-Edition-Startup-Error-On-Linux-Mint-20.x.html
Delete lines in a file(s). In this example lines containing -- are deleted.
sed -i '/--.*/d' ./*
sed -i -e '/^\s*#\([^!]\|$\)/d'
Where: ^ = start of line \s* = zero or more whitespace characters # = one hash mark \([^!]\|$\) = followed by a character which is not ! or end of line.