Thursday, April 2, 2009

Redirection Tricks

Now, 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