tee command

Split program output to console and to a file

Basic usage

$ command | tee out_file.txt

Appending to the output file using -a

$ command | tee -a out_file.txt

Redirecting stderr and stdout

$ command |& tee -a out_file.txt

 

Example

$ ls |& tee -a out_file.txt

 

Notes

  • |& is shorthand for  2>&1

 

References

  • http://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout
  • http://www.gnu.org/software/bash/manual/bashref.html#Pipelines

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *