2>&1 ?
Could anyone tell me what 2>&1 means?
|
What it actually does is a little confusing. The result is easy to understand.
Those numbers are file descriptors that exist for bash by default. 1 is stdout the terminal. 2 is stderr where all errors are reported. What this does is to write error messages to the same place regular output goes, combining both into one stream. For example when you run a job, you may want to keep the good out and also save any error messages all at the same time -- all in one file. |
Technically, the & calls the dup() function.
You can look up dup in the manpages. |
It's a redirect.
2 represents stderr and 1 is stdout Check out Bash-Prog-Intro-HOWTO for more info again....i type so slowly..... |
For example, i have seen the 2>&1 in scripts which are run through cron.
Then if an error occur then a console will open automatically reporting the error. Am i right? |
Quote:
If stdout is your screen then errormessages will go to the screen too when using 2>&1 |
All times are GMT -5. The time now is 05:54 PM. |