Command tee
writes the standard output and copies it into the specified file or files. Use the tee command to view your output immediately and at the same time, store it for future use.
For example, the following will display the out and write to the ziabs.txt file
ls | tee ziabs.txt
If we want copy to the multiple file just pass the file names in sequence
ps -aux | tee ziabs.txt ps.log
We can use tee
with append option for that need to pass the -a
flag
ls | tee -a ziabs.txt
NAME
tee - read from standard input and write to standard output and files
SYNOPSIS
tee [OPTION]... [FILE]...
DESCRIPTION
Copy standard input to each FILE, and also to standard output.
-a, --append
append to the given FILEs, do not overwrite
-i, --ignore-interrupts
ignore interrupt signals
-p diagnose errors writing to non pipes
--output-error[=MODE]
set behavior on write error. See MODE below
--help display this help and exit
--version
output version information and exit