A Clockwork Orange A Clockwork Orange - 1 year ago 51
Bash Question

Delete lines in a text file that containing a specific string

How would I use to delete the whole line in a text file that contains a specific string?

Answer Source

To remove the line and print the output to standard out:

sed '/pattern to match/d' ./infile

To directly modify the file (and create a backup):

sed -i.bak '/pattern to match/d' ./infile