useless
useless

Reputation: 1906

Redirect stdout to stderr but keep it also in stdout

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.

Upvotes: 0

Views: 186

Answers (3)

markp-fuso
markp-fuso

Reputation: 35336

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)

Upvotes: 1

KamilCuk
KamilCuk

Reputation: 141768

Typically:

command | tee /dev/stderr

Upvotes: 2

useless
useless

Reputation: 1906

found a solution:

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

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

Upvotes: 0

Related Questions