[Toybox] sed is tricksy.

Rob Landley rob at landley.net
Mon Oct 20 21:48:50 PDT 2014


sed 0p # has a specific error message in ubuntu. Why?
"sed 1,0p" # is allowed, equivalent to sed 1p

# ^ so matching ranges always include first line.

echo -e "salad\nsalad\nsalad" | sed -n '/salad/,/salad/p'

# ^ starting trumps ending, so matching ranges don't require a gap.

echo -e '\tx' | sed -n '/\t/p' # matches and prints tab and x
echo -e '\tx' | sed -n '\t\txtp' # does not match
echo -e '\tx' | sed -n '\n\txnp' #matches again

Don't mine me, mining corner cases. All of these and more need to go in
sed.tests...

Rob

P.S. Posix says you can't start a line matching regex address with \\
but doesn't say _why_...

 1413866930.0


More information about the Toybox mailing list