Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 9
    Note that doing this one loses the guarantee that ordering will be consistent between the two streams -- if you write, say, five lines to stdout, one line to stderr, and five more lines to stdout, it's not at all guaranteed that the line written to stderr will have five stdout lines before it and five after it when it finally gets flushed. Commented Apr 27, 2018 at 19:54
  • @CharlesDuffy Do you have any extra information on that ? A couple links perhaps ? Commented Apr 28, 2018 at 1:47
  • @SergiyKolodyazhnyy I think the dupe candidate suggested by you and the possible dupe for that question are good for that - both have some discussion on retaining ordering of the output. Commented Apr 28, 2018 at 3:39
  • If the job is only add a prefix, I'd save on sed call with something like while read -r; do echo "$PREFIX$REPLY"; done Commented May 18, 2021 at 9:57
  • @jno depends on the prefix. Something like ts could be used for nicely timestamped output. Commented May 18, 2021 at 10:04