Personal tools
You are here: Home DB2 Useful Unix and Linux Commands Displaying output and copying to a file - tee command
Navigation
Log in


Forgot your password?
 
Document Actions

Displaying output and copying to a file - tee command

Displaying program output and copying to a file (tee command)


tee command, used with a pipe, reads standard input, then writes the output of a program to standard output and simultaneously 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, type the following:
db2 get dbm cfg | tee dbm.out
This displays the standard output of the "db2 get dbm cfg" command on the display device, and at the same time, saves a copy of it in the dbm.out file. If the dbm.out file already exists, it is deleted and replaced unless the noclobber option of the set built-in command is specified.
For example, to view and save the output from a command to an existing file:
ls -l | tee -a program.ls
This displays the standard output of ls -l at the display device and at the same time appends a copy of it to the end of the program.ls file.
The system displays information similar to the following, and the program.ls file contains the same information:
-rw-rw-rw-   1 jones   staff   2301   Sep 19    08:53 161414
-rw-rw-rw-   1 jones   staff   6317   Aug 31    13:17 def.rpt
-rw-rw-rw-   1 jones   staff   5550   Sep 10    14:13 try.doc

Source: http://publib.boulder.ibm.com/infocenter/systems/index.jsp
Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls