On 06/21/2011 06:42 AM, Dominic Ringuet wrote: > On Tue, Jun 21, 2011 at 8:22 AM, Webmaster<[email protected]> wrote: >> For example: >> ls -l /usr/bin | more> redirect_test.log 2>&1 (BLFS 6.3 Page 37) >> What does "2>&1" mean? > 2 is stderr >> is a redirector > &1 is stdout > > ===>Without it, both normal output and errors will be printed in the file;===< did you really mean this? according to this test, your statement is not true.
nolan@retired:~$ ls -l /not/a/file > yes.file ls: cannot access /not/a/file: No such file or directory nolan@retired:~$ cat yes.file nolan@retired:~$ ls -l yes.file -rw-r--r-- 1 nolan nolan 0 2011-06-21 10:08 yes.file nolan@retired:~$ ls -l /not/a/file > yes.file 2>&1 nolan@retired:~$ nolan@retired:~$ cat yes.file ls: cannot access /not/a/file: No such file or directory nolan@retired:~$ ls -l yes.file -rw-r--r-- 1 nolan nolan 57 2011-06-21 10:11 yes.file nolan@retired:~$ Have I missed something? with it, normal output goes in the file and error is on the screen. > (unless standard output goes somewhere else) > > Examples: > > ls -al /usr> test.log 2>&1 > * the content of /usr will goes in test.log > > ls -al /usr> test.log > * the content of /usr will goes in test.log > > So far, there are no errors, the behavior is the same in both > instances. The expression becomes meaningful only if there is an > error: > > ls -al /non/existant/directory> test.log 2>&1 > * will print "No such file or directory" on screen, leaving test.log empty > > ls -al /non/existant/directory> test.log > * will print "No such file or directory" in test.log -- http://linuxfromscratch.org/mailman/listinfo/lfs-support FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
