Sunday, December 9, 2012

Shell script, redirecting a script's output in a simple way

This is really the simplest way I could find: just embed the redirection thing in the script itself, live happily ever after.

main_function() {
        echo Ciao
        echo Miao

main_function > pippo.log 2>&1

If you want to see the output while executing:
main_function | tee -a $LOG_FILE 2>&1

No comments: