redirect to both file and std output at the same time

hello

can some one please help me to redirect the output of a command to both std output and a file. this is little urgent.

sridhar

Use the 'tee' command:

/usr/bin/generate_stdout | tee -a /filename/to/append/sdtout/to.txt | ./my_command

I'm not sure which unix you are using, but if you have the 'tee' command installed, you can use that.

# echo hello | tee outfile
hello
# cat outfile
hello

you can use the -a option to just append to the file

# echo world | tee -a outfile

and now you have

# cat outfile
hello
world

If you dont have tee, and cant install it, then you are probably looking at some crazy file descriptor re-assignment/redirection, of which i'm not entirely keen.