Sample Header Ad - 728x90

What is the `tee` command in Linux?

18 votes
3 answers
13408 views
I am trying to interpret the following tee command: cat colors.txt words.txt | tee colorsAndWords.txt | wc Is my understanding, as follows, correct? 1. cat colors.txt words.txt: This command concatenates the contents of the colors.txt and words.txt files and sends the combined output to the standard output (the terminal). 2. | tee colorsAndWords.txt: The | (pipe) symbol takes the output of the previous command and passes it as input to the tee command. tee is used to both display the data on the standard output (usually the terminal) and write it to a file. In this case, it writes the concatenated output to a file named colorsAndWords.txt. 3. | wc: The final | wc takes the output of the tee command, which is still the concatenated content, and passes it to the wc command. wc is used to count the number of lines, words, and characters in the text it receives as input.
Asked by Nosail (281 rep)
Oct 26, 2023, 09:47 AM
Last activity: Oct 28, 2023, 08:05 PM