Not sure this suits you, but if it's about selecting lines from a stream of text, sed
should always sort you out. Check the examples below:
I want to output only those lines not matching a certain regular expression (regex) - in this example, omit all lines containing the word "pipe".
$> echo -e "this is a line\nthat is a line\nthis is a piped line\nthat is a line in a pipe" | sed '/pipe/d'
this is a line
that is a line
In the next one, output only those lines containing the word "pipe"
$> echo -e "this is a line\nthat is a line\nthis is a piped line\nthat is a line in a pipe" | sed '/pipe/!d'
this is a piped line
that is a line in a pipe
Alternatively, ouput only the 2nd and 3rd lines:
$> echo -e "this is a line\nthat is a line\nthis is a piped line\nthat is a line in a pipe" | sed -n '2,3p'
that is a line
this is a piped line
And many more examples and possibilites... Check out sed1line
Definitely, there are many more capable alternatives too, awk
, perl
, etc