Bash redirection: save stderr/stdout to different files and still print them out on a console

Posted by Alby on Stack Overflow See other posts from Stack Overflow or by Alby
Published on 2012-10-17T05:52:24Z Indexed on 2012/10/18 11:01 UTC
Read the original article Hit count: 148

Filed under:

Here is a simple program.

class Redirection {

public static void main (String args[]){
    System.out.println("Hello World_Stdout");
    System.err.println("Hello World_Stderr");
}

}

I want to see the all the outputs on a console, but at the same time I want to store stdout and stderr in different files. I tried the following command, to no avail.

$java Redirection 3>&1 2>stderr 1>stdout 1>&3 2>&3

stderr& stdout files have the file size of 0.

So basically I want to do what "tee" command does but I also want to capture stderr as well.

© Stack Overflow or respective owner

Related posts about bash