Linux tee command

Linux 命令大全Linux Command Collection

The Linux tee command is used to read data from standard input and output its contents to a file.

The tee command reads data from the standard input device, outputs its contents to the standard output device, and simultaneously saves it to a file.

Syntax

tee [-ai][--help][--version][文件...]

Parameters:

  • -a or --append: Append to existing files rather than overwriting them.
  • -i or --ignore-interrupts: Ignore interrupt signals.
  • --help: Online help.
  • --version: Display version information.

Examples

Use the command "tee" to save user input data to both files "file1" and "file2" at the same time. Enter the following command:

$ tee file1 file2                   #在两个文件中复制内容 

After executing the above command, the user will be prompted to enter the data to be saved to the file, as shown below:

My Linux                        #提示用户输入数据  
My Linux                        #输出数据,进行输出反馈  

At this point, you can open the files "file1" and "file2" respectively, check whether their contents are both "My Linux", and then determine whether the command "tee" was executed successfully.

Linux 命令大全Linux Command Collection

Other Extensions