This article will show you how to redirect command errors to file in Bash.
command 2> errors.txt
If you want data to be added to an existing file use
In the example below, we will try to execute a wrong command that bash will not recognize - normally the result would be the message
bash: sample_invalid_command: command not found.
$ abcd 2> errors.txt
After executing the above line, no message will be displayed, but the contents of the
errors.txt file will looks like this:
bash: abcd: command not found