Write STDERR To A File Instead Of A Terminal
September 2023
TL;DR
some_command &> output.txtThat line runs a command and sends both STDOUT and STDERR to the "output.txt" file.
Notes
-
The command works in some shells (e.g. bash and zsh) but not others (e.g. sh and ksh). If it doesn't work, try:
command > output.txt 2>&1
(There can't be a space between the
>and&characters) -
Sending STDOUT to one file and STDERR to another is done with:
command > output.txt 2> error.txt
end of line