Re: Print ranges without its BEGIN and END patterns

"[email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
It seems you are trying to just print the range, but not print the range delimiters. That is a very interesting problem and a creative solution. 
 

 

 My only problem with the script is it relies on the //!p syntax, which is fine ("print if does not match previous search pattern") except it seems unclear what "previous search pattern" is at times. Tim explains what the "previous search pattern" is and he is right. But to me it seems either guesswork, or hindsight. Trying to predict what the script would do without seeing the output first be confusing to most people, I think. So I would suggest a possible alternative:
 

 

 $ cat in
first
second
third
third
fourth
fifth
 

 

 $ sed -n '/second/,/fourth/ {/second/ d; /fourth/ d; p}' in
third
third

 

 

 The alternative is longer and less elegant. But to me it's clearer, because I would be able to predict the outcome.
 

 

 Daniel



[Non-text portions of this message have been removed]
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.