What does the tee Command do in Linux?
The tee Command Standard Input (stdin) is reading, and it is standard output, one or more files. Tea is usually part of a pipeline, and how many commands can follow and precede it.
The tee command reads the standard input and reads one or more files for the standard output. The command is named T-splitter used in plumbing. It breaks the production of a program so that it can be displayed and protected in a file. It works at once, the two tasks and copies the specified files or variables or results.
There are a few options as below:
- –a option: Suppose we have the file 1. txt. Do not restrict the file, but add to the given file.
- –help option: It displays the help message and exit.
- –version option: It displays the version information and exit.
The tee command can be used to:
- Append to the given file: The default behaviour of the file is overwriting the file’s content. To add the command output to the end of the file, use the argument -a (or --append).
- Write to multiple files: The numerous files can be written using the tee command followed by any number of files to write the same output.
- Hide the output: It tells the tee command to store the command output in a file and skip the terminal output.
- Redirect output of one command to another: The tee does not have to be the last command in the pipeline, so it can be used to forward the output to another command.
- Ignore interrupts: To enable tee to exit correctly, add the argument –i(or –ignore-interrupts) even after the previous command has been interrupted.
- Using tee with sudo: Place the sudo command right before the tee command to enable tee to write to a root-owned file or file belonging to another user.