How to delete lines between patterns with custom delimiters

Viewed 44

I'm using sed (GNU sed) 4.4

sed '\@a@d' conf.js I can delete with a custom delimiter

sed '/a/,/b/d' conf.js I can delete an inclusive range with a pattern

sed '\@a@,@b@d' conf.js` `sed: -e expression #1, char 7: unexpected `,' But I cannot delete an inclusive range with a custom delimiter because it doesn't expect the comma

How can I delete lines between two patterns, while using a custom delimiter?

1 Answers

You need to escape a custom delimiter for each pattern. So this should work:

sed '\@a@,\@b@d' conf.js

btw this should work on POSIX sed also not just on gnu version.

Related