I'm interested in figuring out a way to delete an entire line in a text file that contains a particular string. This will be for a text file that operates like a phone book containing names, address, phone numbers, etc
[Ex]
John Smith, 123 Fake St, 555-555-555
I want to know how I can search for a particular name and remove the entire line that contains it. So for the example above, I would search for "John" or "Smith" or "John Smith" and remove the entire line that contains those words.
Would I used grep, or sed for this? I want it to make a permanent change to the file
You could use
d
command fromsed
.To remove all lines containing word John, you would do
In case of Multiple criterions, use the
-e
command