Output text from a command to the screen and save it to a file in Unix
You can use the tee
command to output text from a command
both to the screen and to a file. The tee
command takes
data from standard input and writes it to standard output as well as
to a file.
For example, without the tee
command, you would be forced
to redirect the output of the who
command to a file, and
then print the file to the screen with two separate commands. In other
words, to redirect the output of the who
command to the
file who_output
and then print it to the screen, you
would have to type the following two commands:
who > who_output
cat who_output
However, using the tee
command, you can shorten the above
process as follows:
who | tee who_output
For more information about the tee
command, see the
online manual. At your Unix shell prompt, enter:
man tee
At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.
This is document abys in the Knowledge Base.
Last modified on 2023-06-29 12:46:37.