Shortcut to forward standard output and error to another command
You have command in bash and want to pipe the output and error to another command. Usually I would do like this:
command 2>&1 | tee -a log.txt
This will pipe the error and output to tee
, which will append it into log.txt
and print it to the console as well.
There exists a shortcut in bash 4 (via this answer):
command |& tee -a log.txt