Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

tee
linux
communitycreator

What is the tee command in Linux?

abhilash

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The tee command in Linux reads the standard input and writes it to one or more files, along with the standard output.

Syntax

tee [OPTIONS] FILES...

Below are a few options that can be used.

Option Description
-a Appends to a file
-v Displays version information
--help Displays the command description and options

Code

In the code below, we use the tee command to redirect the output of the echo command to the file as well as to the terminal. Then, we use the grep command to check if the file is created. Finally, we print the contents of the file created by the tee command.

echo "hello-educative" | tee file.txt
echo "-----"
ls -l | grep file
echo "-----"
cat file.txt

RELATED TAGS

tee
linux
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring