Posts

Showing posts with the label io-redirection

What does >& mean?

What does >& mean? I was a little confused by this expression: gcc -c -g program.c >& compiler.txt I know &>filename will redirect both stdout and stderr to file filename . But in this case the ampersand is after the greater than sign. It looks like its of the form M>&N , where M and N are file descriptors. &>filename filename M>&N M N In the snippet above, does M=1 and N='compiler.txt' ? How exactly is this different from: M=1 N='compiler.txt' gcc -c -g program.c > compiler.txt (ampersand removed) My understanding is that each open file is associated with a file descriptor greater than 2. Is this correct? If so, is a file name interchangeable with its file descriptor as the target of redirection? 2 Answers 2 This is the same as &> . From the bash manpage: &> Redirecting Standard Output and Standard Error Th