help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to merge stdout and stderr yet distinguish what is f


From: Dennis Williamson
Subject: Re: [Help-bash] How to merge stdout and stderr yet distinguish what is from stdout and what is from stderr?
Date: Sun, 4 Feb 2018 16:34:06 -0600

On Feb 4, 2018 3:34 PM, "Peng Yu" <address@hidden> wrote:

Hi,

`cmd 2>&1` can be used to merge stdout stderr into one stream. But the
content from stdout and stderr are not distinguishable anymore.

Is there a way to not only merge stdout and stderr but also prepend
each line from stdout with a prefix and prepend each line from stderr
with a different prefix (e.g., 'o' and 'e' respectively) so that they
are distinguishable (we assume that there will be no merged lines
coming from both stdout and stderr)?

Maybe this can be done through an external program, but I am not sure
how to implement, especially, if I want the order of the lines
combined from both streams unchanged whether there are prefixes or
not.

Does anybody know a solution to this problem? Thanks.

--
Regards,
Peng


Please see https://mywiki.wooledge.org/BashFAQ/106


reply via email to

[Prev in Thread] Current Thread [Next in Thread]