Tee (command): Difference between revisions
No edit summary |
No edit summary |
||
Line 44: | Line 44: | ||
[[Category:Unix software]] |
[[Category:Unix software]] |
||
[[Category:Inter-process communication]] |
[[Category:Inter-process communication]] |
||
{{software-stub}} |
|||
[[ja:Tee (UNIX)]] |
[[ja:Tee (UNIX)]] |
Revision as of 20:04, 12 December 2007
It is proposed that this article be deleted because of the following concern:
If you can address this concern by improving, copyediting, sourcing, renaming, or merging the page, please edit this page and do so. You may remove this message if you improve the article or otherwise object to deletion for any reason. Although not required, you are encouraged to explain why you object to the deletion, either in your edit summary or on the talk page. If this template is removed, do not replace it. This message has remained in place for seven days, so the article may be deleted without further notice. Find sources: "Tee" command – news · newspapers · books · scholar · JSTOR Nominator: Please consider notifying the author/project: {{subst:proposed deletion notify|Tee (command)|concern=Per [[WP:NOT]], Wikipedia is not an instruction manual.}} ~~~~ Timestamp: 20071212194500 19:45, 12 December 2007 (UTC) Administrators: delete |
tee is a Unix command that displays the output of a program and copies it into a file.
Syntax
tee [ -a ] [ -i ] [ File ... ]
Description
The tee command reads standard input, writes its content to standard output and simultaneously copies it into the specified file or files.
Flags
- -a Adds the output to the end of File instead of writing over it.
- -i Ignores interrupts.
Exit Status
This command returns the following exit values:
- 0 The standard input was successfully copied to all output files.
- >0 An error occurred.
Note: If a write to any successfully opened File operand is not successful, writes to other successfully opened File operands and standard output will continue, but the exit value will be >0.
Examples
- To view and save the output from a command at the same time:
lint program.c | tee program.lint
This displays the standard output of the command lint program.c at the workstation, and at the same time saves a copy of it in the file program.lint. If a file named program.lint already exists, it is deleted and replaced.
- To view and save the output from a command to an existing file:
lint program.c | tee -a program.lint
This displays the standard output of the lint program.c command at the workstation and at the same time appends a copy of it to the end of the program.lint file. If the program.lint file does not exist, it is created.
- To allow escalation of permissions:
echo "Body of file..." | sudo tee root_owned_file > /dev/null
This example shows tee being used to bypass an inherent limitation in the sudo command. sudo is unable to pipe the standard output to a file. By dumping its stdout stream into /dev/null, we also suppress the mirrored output in the console.
See also
- The script command
- List of Unix programs
- A good faq on Linux I/O Redirection "Linux I/O Redirection" with tee