Michael
Michael

Reputation: 14218

Delete matching line with sed

I currently have this sed command that replaces foo.us.param=value with foo.param=value:

sed -i -e 's/\.us\./\./' file.txt

I also need it to delete any lines that contain .eu. anywhere but leave all other lines untouched. Any help would save me a long time trying to figure this out alone and would be greatly appreciated.

Upvotes: 2

Views: 448

Answers (2)

gbtimmon
gbtimmon

Reputation: 4322

instead of sed you could also use grep

grep -v '\.eu\.'

Upvotes: 0

Barmar
Barmar

Reputation: 780724

sed -i -e 's/\.us\./\./' -e '/\.eu\./d' file.txt

Upvotes: 2

Related Questions