开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜