R14
R14

Reputation: 162

Deleting text between two strings using sed

I am trying to delete all of the text between two strings in a number of txt files, including the strings themselves.

The strings are SUBJECT: and BODY:

This is what I have been using:

sed '/SUBJECT:/,/BODY:/d' *.txt

It appears to run without issue, but there are no changes to the files upon completion.

Upvotes: 0

Views: 1451

Answers (1)

iobender
iobender

Reputation: 3486

Add the -i flag to modify the files in place: sed -i '/SUBJECT:/,/BODY:/d' *.txt

Upvotes: 3

Related Questions