If you're running a program and you want to send its output to a file - but
you want to see the output on your screen, too, so you can stop the
program if something goes wrong - you can use tee
program reads its standard input and writes it to one or more
(The CD-ROM has the GNU version.)
A pipe may buffer
the output of a program, collecting it in chunks
and spitting it out every so often.
If the program's output comes slowly and feeds tee
through a pipe,
there might be long delays before you see any output.
In that case, it's better to use
to redirect output to a file,
put the program into the background, and watch the output with
Or use a program like
for saving results in the middle of a long pipeline of commands.
That's especially good for debugging.
For example, you could type:
| tee prog.out | sed -f sedscr | tee sed.out |
to save the output of prog
in the file prog.out
and also pipe
it to the sed
command, save sed
's output in sed.out
also pipe it...
If you want to add to a file that already exists, use the -a