16 June 2016

tee

  1. info

    1. redirect data to a file

    2. and provide a copy of redirect data as stdin for next set of commands

    3. read from stdin only

  2. demo

    1. create 2 files

       $ echo a1 > a1.txt
       $ echo a2 > a2.txt
      
    2. write a*.txt to out.txt and print out

       $ cat a* | tee out.txt | cat -n
           1 a1
           2 a2
      
       $ cat out.txt
       a1
       a2
      
    3. default tee overwrite the file

       # using `-a` to append
       $ cat a* | tee -a out.txt | cat -n
      
    4. use stdin as a command argument using -

       $ echo who is this | tee -
      


blog comments powered by Disqus