From this question I learned how to add a prefix to each output of a command:
command | sed "s/^/[prefix] /"
But this only adds the prefix for each line from stdout
.
I successfully used the following to add the prefix also to stderr
output.
command 2>&1 | sed "s/^/[prefix] /"
But this sends the result to stdout
only.
How can I prefix any output of command
while pushing the lines to the previous output (preserving both stdout and stderr)?