Search code examples
http-redirectstdoutstderr

redirect stdout and stderr to seperate files and to screen


I have been through quite a few variants of this question but none seems to do exactly what I want. I would like to start csh, have STDOUT go to one file and to the screen, and have STDERR go to a different file, and to the screen as well.

This command: csh > stdout_file.txt 2> stderr_file.txt

gets STDOUT and STDERR to different files, but than nothing goes to the screen. How can I get what is written to the files go to the screen as well? I assume tee should be a part of this, but whatever I try gives my syntax errors.


Solution

  • ((csh | tee f1) >`tty`) 2>&1 | tee f2
    

    or maybe

    ((csh | tee f1) >`tty`) |& tee f2