Bash /
RedirectionRedirection is the process by which information that was supposed to go to one location is sent to another. Output redirectionMost common of all is the output redirection, which allows to save too long (or cumbersome) output into a file instead of displaying it on the terminal window.
where Error redirectionIn Bash, output comes in two "flavours": standard and error. The above only redirects standard output and error messages will still be displayed on the terminal. To redirect errors into their own file
Redirecting bothUsing the above, only one of the two outputs is redirected, meaning that potentially important context might be missing. To redirect both outputs:
which redirects standard output into Redirecting from withinWhen writing a script, it is often useful to pre-set output redirection. This is done in the header of the script. For example, to separate Bash error messages from the main output: #!/bin/bash -- exec 2> errorFile |