Results 1 to 3 of 3
from time to time I see something like this:
test.ksh > test.log 2>&1
the question is, what does "2>&1" mean?
Thanks,...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-27-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 1
question on scripting
from time to time I see something like this:
test.ksh > test.log 2>&1
the question is, what does "2>&1" mean?
Thanks,
- 07-27-2010 #2Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 2,563
I googled
Found quite a number of sites, some with simple explanations, some with convoluted and/or detailed. Here's one explanation:2>&1" mean?
I had no clue before reading your post and doing a search. Got the above from the Linux Journal site below which has lots more info:The incantation 2>&1 means “Send errors (output stream number 2) to the same place ordinary output (output stream number 1) is going to.” By the way, this 2> jazz only works in the Bourne shell and its descendants. The C shell makes it annoying to separate errors from output, which is one of the reasons people avoid programming in it.
Beyond Your First Shell Script | Linux Journal
- 07-28-2010 #3
Yeah, basically there are three "standard" streams of information. Standard input, standard output, and standard error.
So for example, if you used the ls command to list contents of a directory, the results are standard output and defaults to printing to the screen.
If you piped that standard output to a search command, say grep as so
The output of ls becomes the standard input of grep.Code:ls | grep Movies
Standard error outputs diagnostic and error messages, which frequently you don't want. This is frequently directed to /dev/null, basically sending it off into nothingness.
In some cases maybe you want standard output and errors printed to the screen, or you want the program to be quiet and send both of those to /dev/null, or send them to a log file, or whatever.
Standard streams - Wikipedia, the free encyclopedia
Cool Solutions: /dev/null
BASH Programming - Introduction HOW-TO: All about redirection
http://www.xaprb.com/blog/2006/06/06...vnull-21-mean/


Reply With Quote
