I know that having an
& at the end of a command makes it run in the background. I was wondering what does
&Number mean? I was looking at a script that has some commands running with
&1 and some with
migrated from stackoverflow.com Sep 3 '10 at 20:03
This should be migrated to SuperUser, but the answer is that they refer to file descriptors. &1 is standard output, and &2 is standard error, so a program run like this:
Redirects descriptor 2 (standard error) to descriptor 1 (standard output)
A common use of this is to do something like this:
Which redirects standard output into a file, and then standard error into standard output, so that you get both regular and error output captured in the file.
For Bourne type shells (bash etc.)
merges the standard error output (file descriptor 2) with the standard output (file descriptor 1) and writes both of them into
The '&' indicates a file descriptor. &1 is stdout, and &2 is stderr.
If you haven't found a good site for learning shell scripting already, I recommend this one: