I/O redirections are one of the prettiest things we have in linux (IMO!) Following are commands and their usage.
command_output >> file
Redirects stdout to a file. Creates the file if not present, otherwise appends.
Truncates the file to zero length. If file is not present, creates zero-length file (same effect as
Redirects stdout to the file “filename”.
Redirects and appends stdout to file “filename”.
Redirects stderr to file “filename”.
Redirects and appends stderr to file “filename”.
Redirects both stdout and stderr to file “filename”.
Redirects stderr to stdout. Error messages get sent to same place as standard output.
Some quality explanation now ;) Take the example of this command:
cmd >> file.log 2>&1
This command will redirect all the output of command(cmd) into
2 refers to Second file descriptor of the process i.e., stderr
> refers to redirection
&1 means that the target of redirection would be same as
1 i.e, first descriptor i.e, stdout.