On August 6, 2008 18:35, in comp.unix.shell, puzzlecracker
Post by puzzlecrackerCan someone explain how tee command works. thanks
The tee(1) ("man 1 tee") command copies everything from it's standard input
to both it's standard output, and to each file named in it's arguments.
So, the pipeline
echo "Hello there" | tee output_file | sed 's/there/here/'
will
echo the string "Hello there" to stdout, which is piped into tee's stdin
tee will copy the string "Hello there" to the file called output_file, and
to it's own stdout, which is piped into sed's stdin
sed will read it's stdin, change the first occurrence of the string "there"
to "here", and send all the read data to stdout
resulting in
the file output_file containing the string "Hello there", and
the string "Hello here" showing on the screen.
~/tmp $ ls
~/tmp $ echo "Hello there" | tee output_file | sed 's/there/here/'
Hello here
~/tmp $ ls
output_file
~/tmp $ cat output_file
Hello there
~/tmp $
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------