Home > Net >  Redirect stdout to stderr but keep it also in stdout
Redirect stdout to stderr but keep it also in stdout

Time:04-02

I want to be able to redirect stdout to stderr but keep the content of stdout in there also. So not exactly redirect but clone or duplicate.

CodePudding user response:

Typically:

command | tee /dev/stderr

CodePudding user response:

found a solution:

mycommand | awk '{print; print | "cat 1>&2"}' > /tmp/stdout-content

# and stout is also in stderr (visible in the terminal)

CodePudding user response:

If the sole purpose is to split stdout to terminal and a file, another idea:

mycommand | tee -a /tmp/stdout-content

NOTE: -a says to append to the file; to overwrite the file each time mycommand is run you can remove the -a (which leaves you with the same thing KamilCuk just posted)

  • Related