LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   copying stdout and stderr to seperate files (https://www.linuxquestions.org/questions/linux-general-1/copying-stdout-and-stderr-to-seperate-files-526985/)

dasy2k1 02-09-2007 05:58 AM

copying stdout and stderr to seperate files
 
i want to run a script that creates large quantaties sdtout and posts errors to sterr putting these into 2 seperare files, (eg stdout.txt and stderr.txt) (extentions only for conviniance!)

however i also want thease to do to stdout and std error on the screen.

i have been using "tee" to do this ie.
command | tee [filename]
but this doesnt do anything with stderr (which is more impiortant that stdout)

what would be the best way to do this?

zulfilee 02-09-2007 06:13 AM

command 2>&1 | tee filename

This will redirect standard error into stdout.
So the file will have both :)

varun_shrivastava 02-09-2007 06:41 AM

redirect your stderr to stdout using
2>&1 like
Code:

echo "hi" 2>&1  | tee -a a.txt;


All times are GMT -5. The time now is 02:03 AM.