Wednesday, August 12, 2009

Tee time

Have you ever needed to write something to file and watch it on the screen at the same time? If so, tee command is your friend. You can pipe anything to tee and it will show it on the screen as well as write to the file (or even better - multiple files) at the same time. The useful switch -a means append mode - the data are added at the end of file instead of erasing it. Let's see and write current time and date to three files - date1, date2 and date3:

$ date | tee -a date1 date2 date3

No comments:

Post a Comment