[Bash] Sending stdout and stderr to single file

Remember: To send both the stdout and stderr messages from the console to a file do:

$ app > log.file 2>&1

If you want to send everything to a black-hole just replace log.file with /dev/null.

$ app > /dev/null 2>&1

If ever confused about the syntax, do man bash and search for REDIRECTION for more gyan

Update:
It is good idea to use tee, which lets you see the output as well as write it to a file.

$ app 2>&1 | tee file.log

No comments: