STDIN is FD 0, while STDOUT is FD 1, and STDERR is FD 2.
To redirect the errors to the output stream use this: 2>&1
Here '&' tells that it is a FD(file descriptor) and not an ordinary file named '1'.
There are lots of redirection symbols that you can use, and here are some of them:
< file | means open a file for reading and associate with STDIN. |
<< token | Means use the current input stream as STDIN for the program until token is seen. We will ignore this one until we get to scripting. |
> file | means open a file for writing and truncate it and associate it with STDOUT. |
>> file | means open a file for writing and seek to the end and associate it with STDOUT. This is how you append to a file using a redirect. |
n>&m | means redirect FD n to the same places as FD m. Eg, 2>&1 means send STDERR to the same place that STDOUT is going to. |
No comments:
Post a Comment