Webmaster wrote:
> For example:
> ls -l /usr/bin | more > redirect_test.log 2>&1 (BLFS 6.3 Page 37) What does
> "2>&1" mean?
You got two nice explanations; I thought perhaps a little more
detail would help. However, this is a basic UNIX shell type
question, and something someone embarking upon building
LFS is normally expected already to understand.
Suppose you have a program xyz. To redirect the standard output
you would use
$ xyz > redirected-ouput-file
Now programs have three standard files associated with fd 0,
fd 1, and fd 2 ("file descriptor"). 0 is stdin (standard input)
1 is stdout (standard output "normal output") and 2 is
stderr (standard error "error output"). To redirect stdin one uses
the < symbol
$ xyz < redirected-input-file
causes redirected-input-file to be read rather than your keyboard.
One can specify which fd is being redirected by preceding the
symbol > with the fd, like this:
$ xyz 1> redirected-stdout-file 2> redirected-stderr-file
If one wants BOTH outputs to go to the stdout file, then one
uses the &1 as the redirected output, like this
$ xyz 2>&1
this makes fd 2 "point to" the same file as fd 1. So,
$ xyz 1> redirected-combined-output 2>&1
puts both fd 1 (stdout) and fd2 (stderr) in one combined output
file.
It is important that the redirections take place in the order
shown.
$ xyz 2>&1 1> redirected-combined-output
does something different. It makes fd 2 (stderr) go to where
fd 1 goes (screen), and then makes fd 1 go somewhere else.
Mac
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I speak only for myself, and I am unanimous in that!
--
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page