1.) stdout to a file
The output of a command will redirect to another file.
Eg: ls -l > list.txt
2.) stderr to a file
The following command will redirect the stderr ouput of a program to a new file.
Eg: grep sibu * 2> grep-errors.txt
Here, a file called ‘grep-errors.txt’ will be created and it will contain what you would see the stderr portion of the output of the ‘grep sibu *’ command.
3.) Stdout to Stderr
This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout.
Eg: grep sibu * 1>&2
Here, the stdout portion of the command is sent to stderr..
4.): stderr to stdout
This will cause the stderr ouput of a program to be written to the same filedescriptor than stdout.
Eg: grep * 2>&1
Here, the stderr portion of the command is sent to stdout.
5.) stderr and stdout 2 file
This will place every output of a program to a file. This is suitable sometimes for cron entries, if you want a command to pass in absolute silence.
Eg: rm -f $(find / -name core) &> /dev/null
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.