bash tee - ghdrako/doc_snipets GitHub Wiki

command | tee [options] [file ...]

file is the name of the file or files you want to send the output to

ls | tee dirlist.txt
ls | tee >(grep "file") >(sort) # list the contents of the current directory and send the output to both the grep and sort commands
ls | tee -a dirlist.txt # -a option to append the output to an existing file instead of overwriting it
ls | tee -i dirlist.txt # -i option to ignore the interrupt signal (SIGINT) and continue running even if you press Ctrl+C