Redirect stderr and stdout in Bash [duplicate]
do_something 2>&1 | tee -a some_file
This is going to redirect standard error to standard output and standard output to some_file
and print it to standard output.
You can redirect stderr to stdout and the stdout into a file:
some_command >file.log 2>&1
See Chapter 20. I/O Redirection
This format is preferred over the most popular &>
format that only works in Bash. In Bourne shell it could be interpreted as running the command in background. Also the format is more readable - 2 (is standard error) redirected to 1 (standard output).