Click to See Complete Forum and Search --> : What doest it mean : 2>&1


nopri
02-02-2001, 11:09 PM
Hello !
Anyone can help me ? I have no idea about 2>&1, found recently in may scripts ??

The King Ant
02-02-2001, 11:45 PM
I think it means that all the output from the program before the "2>&1 >" is sent to whatever is after the "2>&1 >"

So...
"ls 2>&1 > /home/mark/filelisting.txt"
The ls command would list the files, but all the output is saved the the /home/mark/filelisting.txt file. Try it...

pikachu
02-03-2001, 12:20 AM
king ant is correct when he says "all" output.

0 = standard input
1 = standard output
2 = standard error

so in the above construct, instead of having standard output and diagnostic/standard error output display to the screen (default), they are "redirected" to either a defined file or the shell will create a file if the file doesn't already exist.

nopri
02-03-2001, 02:18 AM
Thanks, I'll try it ... :rolleyes: