Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On a Linux system, how would I redirect stdout to stderr?

I think its the case that you can't just assign the stdout to stderr because other things might have already cached (?) stdout by the time the reassignment takes place.

So how do I do this (using Linux)?

like image 402
nodebase Avatar asked May 30 '15 05:05

nodebase


People also ask

How can I redirect stdout and stderr?

Understanding the concept of redirections and file descriptors is very important when working on the command line. To redirect stderr and stdout , use the 2>&1 or &> constructs.

What is stdout and stderr in Linux?

The Linux Standard StreamsText output from the command to the shell is delivered via the stdout (standard out) stream. Error messages from the command are sent through the stderr (standard error) stream. So you can see that there are two output streams, stdout and stderr , and one input stream, stdin .


1 Answers

To redirect the stdout to stderr, use your command as follows :-

$ command-name 1>&2

where command-name is the command you're going to feed, 1 represents stdout and 2 represents stderr .

like image 51
Am_I_Helpful Avatar answered Oct 02 '22 18:10

Am_I_Helpful