Your first sed
example doesn't work for the second and following blocks, because /!/q
(the backslash may lead to undefined behaviour, so I drop it) is already executed for the first !
and the script stops there (same for the exit
of the awk
script). So execute it only after the block, use
sed -n '/2\/1\/6.2062/,/!/{p;/!/q;}'
But a simple
sed -n '/2\/1\/6.2062/,/!/p'
like in your second attempt will also work, if you have no problem with wasting some cpu cycles.
And for future scripts, I suggest to use a different delimiter of the address pattern if it contains slashes like
sed -n '\_2/1/6.2062_,/!/p'
Easier to read, right?
And yes, you can also use !d
:
sed '\_2/1/6.2062_,/!/!d'