tee: Direct output to standard output and File
Posted by Joys of Programming on in Linux
With linux pipes, you can direct the output of one program as an input to the other. But using pipes, you can only direct the output to another program. But if you wish to direct the output to the standard output as well as to a file, you can still use tee.
Take for example, if you want to list the contents of a directory on the terminal as well as save to a file.
ls dir | tee dir_contents file1.txt file2.txt file3.txt
Comments:
You could just forget about having to pipe the out put into yet another file and just use “>” to redirect output directly into a text file instead. you could just forget piping and just use “>” to redirect output directly into a text file instead.
e.g.:
ls dir > dir_contentsAny pathrouting is valid too.
e.g.:
ls dir > path/to/textfileyou could read from the pipe too