Comment

Comment by gwu78

"... is silly, there are better ways."

I see this usage often where it seems like

  grep pattern1 | grep -v pattern2 
can be replaced by

  sed -n '/pattern1/d;/pattern2/p'
or at least

  sed '/pattern1/!d' | sed '/pattern2/d'
or

  sed -n 's/pattern1pattern2//g;/pattern2/p'
But I must be missing something obvious.

For example look at the "grep -v" usage here:

https://github.com/thomwiggers/qhasm/raw/master/qhasm-arm

Is there something wrong with using

   sed '/^op:livefloat80:/d'
Moreover, in the last line, why not use

  sed 's/\$/#/g'
instead of

  tr '$' '#'
Apologies if I am missing the obvious.
parent gwu78 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton