Linux file IO redirection matrix
Borrowing from this amazing post about Linux file IO redirection here is a cool table that breaks down how to get the data where you want it.
Syntax | TermStdOut | TermStdErr | FileStdOut | FileStdErr | File |
---|---|---|---|---|---|
command > |
no | yes | yes | no | create |
command >> |
no | yes | yes | no | append |
command 2> |
yes | no | no | yes | create |
command 2>> |
yes | no | no | yes | append |
command &> |
no | no | yes | yes | create |
command &>> |
no | no | yes | yes | append |
command | tee |
yes | yes | yes | no | create |
command | tee -a |
yes | yes | yes | no | append |
command |& tee |
yes | yes | yes | yes | create |
command |& tee -a |
yes | yes | yes | yes | append |