Print ranges without its BEGIN and END patterns
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <C85CF0D4716EC645B474670C6D162B9941DF12DE@CITYWMX0108.city.net.ffm> |
Hi there,
I'm really new to using sed. While experimenting in order to print ranges without its BEGIN and END patterns I accidentially came across that given a string variable:
VAR=$'first\nsecond\nthird\nfourth\nfifth'
...and mangling it by...
NEWVAR="$(echo "$VAR" | sed -n '/second/,/fourth/{//!p}')"
...then...
echo "$NEWVAR"
...expands to the string "third" seeming to successfully eliminate the BEGIN/ END patterns.
Unfortunately I didn't find this described anywhere in manuals nor the internet. Probably there's anyone out there who can explain whether this is a bug or a feature...and how/why it works.
Best regards
Stephan Seeger