bash - how to redirect stdout and stderr to a file while showing stderr to screen? -


the script should redirect output (stdout , stderr) log file, , display stderr screen (notifying user if error happens). command tee may don't know how write it.

thanks.

p.s., lihao , konsolebox answer, there way keep output in order. example:

$ cat test.sh echo "to stdout..1" echo "to stderr..1" >&2 echo "to stdout..2" echo "to stderr..2" >&2  $ sh test.sh 2>&1 >test.log | tee -a test.log stderr..1 stderr..2  $ cat test.log stdout..1 stdout..2 stderr..1 stderr..2 

command: { sh test.sh 2> >(tee /dev/fd/4); } 4>&1 >test.log has same output.

how following:

cmd args 2>&1 >logfile | tee -a logfile 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -