kevins_office kevins_office - 1 month ago 4x
Linux Question

Concat text around piped input with SED

Using SED on a pipe of input, how can i insert the input in the middle of text which will be used as a linux command?

echo foobar | sed 's/^/one two /'

This will output
one two foobar

How can i use SED to reformat it so the piped value goes in between like
one foobar two

I already tried piping two SED commands in a row however this does not work and the formatting gets messed up. So im looking for a way to do it with a single SED command.

echo foobar | sed 's/\(.*\)/one \1 two/'


one foobar two