Each stream has a number:
| Number | Stream |
|---|---|
| 1 | Standard output |
| 2 | Standard error |
> without a number means 1>: it moves stream 1, the output. To move the error messages, put 2 in front:
text
learner@tidepool:~$ cat prices.txt missing.txt 2> err.txt
tea 4.50
coffee 3.20
learner@tidepool:~$ cat err.txt
cat: missing.txt: No such file or directorycat prices.txt missing.txt
1: stdout
Terminalthe text of prices.txt
cat prices.txt missing.txt
2: stderr
err.txtthe error message
Each stream to its own file
| Line | Output goes to | Errors go to |
|---|---|---|
cmd > out.txt | out.txt | The terminal |
cmd 2> err.txt | The terminal | err.txt |
cmd 2>> err.txt | The terminal | The end of err.txt |
cmd > out.txt 2> err.txt | out.txt | err.txt |
2>> adds to the end, the same as >>.