sed can be used to replace text in a file.
sed -i 's/old-string/new-string/g' file-name.txt
g = Global, replace everything in a file.
s = substitute text
-i = update the file.
Delete lines matching string
To delete lines having a string and print the result.
sed '/string to match/d' file-name.txt
To update the file, use -i option
sed -i '/string to match/d' file-name.txt
Leave a Reply