redirect stdout and stderr in a shell script
February 14th, 2008 by Lawrence David
to send the standard output and standard error streams from your shell script somewhere, place the following at the top of your script:
#!/bin/bash
exec &> output.file;
[the rest of your code]

Something very helpful is to redirect stderr in stdin,
so you can pipe to grep or whatever:
zsh$ cat /foo 2>&1 | grep ‘No such file’
cat: /foo: No such file or directory
If you want to keep only stderr you can do :
zsh$ cat /foo 2>&1 1> /dev/null | grep ‘No such file’
cat: /foo: No such file or directory
Great items from you, man. I have take into account your stuff prior to and you’re just
too wonderful. I actually like what you’ve bought here, really like
what you are saying and the best way through which you say it.
You’re making it enjoyable and you continue to care for to sty it
sensible. I can’t wait to learn much more from you.
This is actualoy a wonderful website.
Greqt post. I was checking continuousl this
blog and I am impressed! Very userful information particularly the last part :
) I care forr such information much. I was looking for this
certan information for a long time. Thank you and best of luck.