A Clockwork Orange A Clockwork Orange - 2 years ago 77
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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download