Read from a standard input and write to a standard file
In golf, a tee is a stand used to support a stationary golf ball so that a player can strike it. In Unix, a tee is a program used to read a standard input and write to a standard output and file.
What is the commonality between golf tee and Unix tee? They are both helpers. They don’t perform by themselves. Just as a golf tee supports the golf ball, Unix tee helps support the command you are running.
The following shows the syntax for tee.
tee [-ai] [file(s)]
-a Append the output to one or more files rather than overwriting them.
-i Ignore interrupt signals.
ls *.png | tee imagelist.txt
In the above example, the ls command lists all the .png files in the current directory. The output will be saved to the imagelist.txt file.
grep home HomePrices.txt | wc -l | tee home1.txt home2.txt
In the above example, the grep command finds all the occurrences of the word home in the text file. Then it does a word count to get the total lines found. Finally, it saves the output to two files called home1.txt and home2.txt. Both files will be identical.
ls -l *.txt | tee -a text_listing.txt
In the above example, the ls command lists all the .txt files in the current directory. The output is appended to the file text_listing.txt. If the file does not exist, it creates a new file.
Incoming search terms:
- Allow Trackbacks Allow Comments chandra Subject Homepage Maximum Attachments