How to pipe to file and screen in linux

To do this we use the command tee.. eg

ls -la | tee filename.txt
#or (as shown in my backup script)
rsync -aAXv $DIR* $BKDIR | tee -a $LOG

Note: ‘tee -a’ appends to file instead of the default overwrite.

Leave a Reply

Close Menu
%d bloggers like this: