Summer training at Goeduhub Technologies-Jaipur
Register for Free Certified Workshop on RTU Python Lab (VI SEM):: 01-03-2020 ||  Career options for aspiring CS/ITECEEE or EIC or EEE Engineers
0 like 0 dislike
3 views
in Tutorial & Interview questions by Summer Trainee (7k points)

1 Answer

0 like 0 dislike
by Summer Trainee (7k points)
 
Best answer

Options                        Description

-a, --append Append to the given FILEs. Do not overwrite.

-i, --ignore-interrupts Ignore interrupt signals.

--help Display a help message, and exit.

--version Display version information, and exit.

tee - read from standard input and write to standard output and files.


The tee command is named after the T-splitter in plumbing, which splits water into two directions and is shaped like an uppercase T.

tee copies data from standard input to each FILE, and also to standard output. In effect, tee duplicates its input, routing it to multiple outputs at once.

Write output to stdout, and also to a file

The following command displays output only on the screen (stdout).
$ ls
The following command writes the output only to the file and not to the screen.
$ ls > file
The following command (with the help of tee command) writes the output both to the screen (stdout) and to the file.
$ ls | tee file

Write output from the middle of a pipe chain to a file and pass it back to the pipe 

You can also use tee command to store the output of a command in a file and redirect the same output to another command.
The following command will write current crontab entries to a file crontab-backup.txt and pass the crontab entries to sed command, which will do the substituion. After the substitution, it will be added as a new cron job.
$ crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab

write the output to multiple files 

You can pipe your output to multiple files (including your terminal) by using tee like this:
$ ls | tee file1 file2 file3

Instruct tee command to append to the file 

By default tee command overwrites the file. You can instruct tee to append to the file using the –a option as shown below.
$ ls | tee –a file

Related questions

0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 2, 2019 in Tutorial & Interview questions by Goeduhub Summer Trainee (7k points)
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
 Go to your Branch CSE or IT | ECE | EE, EIC or EEEMECE
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-KOTA | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning(ML)Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
 Goeduhub
About Us | Contact Us   Social::   |  | 
...