sed: delete all lines in a file using sentinel values
I want to do an inclusive delete from a file that looks like the following:
Some text
Some text
#$
Should be deleted
Should also be del开发者_Go百科eted
#$
More text
I want the file to read the following after sed is ran through it:
Some text
Some text
More text
the #$
values should be inclusively removed.
Can someone explain the sed command used to do this as well?
Try this:
sed -e '/^#\$/,/^#\$/d' file
The idea is to match from the first time you see #$
to the second time, and then delete it.
精彩评论