Reputation: 117
I want to delete a line containing a specific string from my file. I do it like that:
sed -i "/example/d" myfile
But my file contains many lines containing strings that contain the string that I want to delete. for example my file contains lines as bellow and I want to delete only the first line that contains "example":
myfile:
example
example1
example2
..
My question is how to do if want to delete only the line that contains exactly my string "example" and keep the other ones.
Upvotes: 4
Views: 12070
Reputation: 799420
Simple. Be more specific.
sed -i "/\bexample\b/d" myfile
Upvotes: 6