Print ranges without its BEGIN and END patterns

"'Seeger, Stephan' [email protected] [sed-users]" <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.