Have noticed this a fewtimes when I’m piping something into sed which does not contain any newlines, sed does not execute.
Example, a stream contains some text (without any newline)
foo
The command:
$echo -n "foo" | sed 's/foo/bar/'
Outputs nothing.
Whereas if I add a newline character to the end of the stream, The command above will output the expected replacement:
$echo "foo" | sed 's/foo/bar/'
bar
I’ve found a lot of situations where I don’t have, and don’t really want a newline character in my stream, but I still want to run a sed replacement.
Any ideas how this can be done would be appreciated.
What environment are you in? What
sedare you using?Because here, I’ve got a better
sed:Note that one way to get a better
sedis to type it asperl -pe, as in: