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 #1
- Join Date
- Jul 2010
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?
- 07-27-2010 #2
- Join Date
- Oct 2007
- Tucson AZ
I googled2>&1" mean?
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
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