Tee (command)
   HOME

TheInfoList



OR:

tee is
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses Science Biology * Seashell, a hard outer layer of a marine ani ...
command Command may refer to: Computing * Command (computing), a statement in a computer language * command (Unix), a Unix command * COMMAND.COM, the default operating system shell and command-line interpreter for DOS * Command key, a modifier key on A ...
that copies data from
standard input In computer programming, standard streams are preconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), ...
to one or more
files File or filing may refer to: Mechanical tools and processes * File (tool), a tool used to remove fine amounts of material from a workpiece. **Filing (metalworking), a material removal process in manufacturing ** Nail file, a tool used to gentl ...
in addition to
standard output Standard may refer to: Symbols * Colours, standards and guidons, kinds of military signs * Standard (emblem), a type of a large symbol or emblem used for identification Norms, conventions or requirements * Standard (metrology), an object t ...
; duplicating the input to each output. The name derives from the tee pipe fitting even though the command duplicates the input into each output instead of dividing the input into portions for each output. The command is often used with
pipes Pipe(s), PIPE(S) or piping may refer to: Objects * Pipe (fluid conveyance), a hollow cylinder following certain dimension rules ** Piping, the use of pipes in industry * Smoking pipe ** Tobacco pipe * Half-pipe and quarter pipe, semi-circu ...
and
filters Filtration is a physical process that separates solid matter and fluid from a mixture. Filter, filtering, filters or filtration may also refer to: Science and technology Computing * Filter (higher-order function), in functional programming * Fil ...
. Similar behaving commands are provided by many shells although syntax varies. The command is provided in
Unix Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
Unix-like A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
systems,
OS-9 OS-9 is a family of real-time, process-based, multitasking, multi-user operating systems, developed in the 1980s, originally by Microware Systems Corporation for the Motorola 6809 microprocessor. It was purchased by Radisys Corp in 2001, a ...
,
DOS DOS (, ) is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible syste ...
(e.g.
4DOS 4DOS is a command-line interpreter by JP Software, designed to replace the default command interpreter COMMAND.COM in MS-DOS and Windows. It was written by Rex C. Conn and Tom Rawson and first released in 1989. Compared to the default, it has ...
,
FreeDOS FreeDOS (formerly PD-DOS) is a free software operating system for IBM PC compatible computers. It intends to provide a complete MS-DOS-compatible environment for running Legacy system, legacy software and supporting embedded systems. FreeDOS ca ...
),
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
(e.g. 4NT,
PowerShell PowerShell is a shell program developed by Microsoft for task automation and configuration management. As is typical for a shell, it provides a command-line interpreter for interactive use and a script interpreter for automation via a langu ...
,
UnxUtils UnxUtils is a collection of utility programs that provide popular Unix-based shell commands ported from GNU implementations as native Windows programs that depend only on Win32 and the Microsoft C- runtime ( msvcrt.dll). The collection wa ...
),
ReactOS ReactOS is a Free and open-source software, free and open-source operating system for i586/amd64 personal computers that is intended to be binary-code compatibility, binary-compatible with computer programs and device drivers developed for Wind ...
and
IBM i IBM i (the ''i'' standing for ''integrated'') is an operating system developed by IBM for IBM Power Systems. It was originally released in 1988 as OS/400, as the sole operating system of the IBM AS/400 line of systems. It was renamed to i5/OS in 2 ...
. The Linux version was written by Mike Parker,
Richard Stallman Richard Matthew Stallman ( ; born March 16, 1953), also known by his initials, rms, is an American free software movement activist and programmer. He campaigns for software to be distributed in such a manner that its users have the freedom to ...
, and David MacKenzie. The FreeDOS version was developed by Jim Hall and is licensed under the
GPL The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first c ...
. Additionally the sponge command offers similar capabilities.


Unix

The typical syntax on a Unix-based system can be described as: tee a i ile... *file... One or more names for files to receive the command input data *-a Append to a file rather than overwriting *-i Ignore interrupts
Process substitution In computing, process substitution is a form of inter-process communication that allows the input or output of a command to appear as a file. The command is substituted in-line, where a file name would normally occur, by the command shell. This all ...
lets more than one process read the standard output of the originating process.. If a write to any file is not successful, writes to other files and standard output continue, but the
exit status In computing, the exit status (also exit code or exit value) of a terminated process is an integer number that is made available to its parent process (or caller). In DOS, this may be referred to as an errorlevel. When computer programs ar ...
will indicate failure with a value greater than 0.


Examples

The following both displays the output of the lint program.c command and saves the output to a file named program.lint; overwriting it if it already existed. lint program.c , tee program.lint The following does the same as the previous example, except for appending the output to an existing file instead of overwriting it. The file is created if it was not pre-existing. lint program.c , tee -a program.lint The following bypasses a limitation of the
sudo () is a shell (computing), shell command (computing), command on Unix-like operating systems that enables a user to run a program with the security privileges of another user, by default the superuser. It originally stood for "superuser do", a ...
command which is unable to pipe standard output to a file. By dumping its stdout stream into /dev/null, output to the console suppressed. This gives the current user root access to a server over ssh, by installing the user's public key to the server's key authorization list. cat ~/.ssh/id_rsa.pub , ssh admin@server "sudo tee -a /root/.ssh/authorized_keys2 > /dev/null" In Bash, the output can be
filtered Filtration is a physical separation process that separates solid matter and fluid from a mixture using a ''filter medium'' that has a complex structure through which only the fluid can pass. Solid particles that cannot pass through the filter ...
before being written to the file—without affecting the output displayed—by using
process substitution In computing, process substitution is a form of inter-process communication that allows the input or output of a command to appear as a file. The command is substituted in-line, where a file name would normally occur, by the command shell. This all ...
. The following removes common
ANSI escape code ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an Escape character#ASC ...
s before writing to ls.txt, but retains them for display. ls --color=always , tee >(sed "s/\x1b mm//g" > ls.txt)


4DOS and 4NT

The syntax on 4DOS and 4NT can be described as: TEE Afile... *file One or more names for files to receive the command input data */A Append to a file rather than overwriting When used with a pipe, the output of the previous command is written to a
temporary file A temporary file is a file created to store information temporarily, either for a program's intermediate use or for transfer to a permanent file when complete. It may be created by computer programs for a variety of purposes, such as when a progra ...
. When that command finishes, processes the temporary file; copying it to the file argument(s) and standard output.


Examples

This example searches the file wikipedia.txt for any lines containing the string "
4DOS 4DOS is a command-line interpreter by JP Software, designed to replace the default command interpreter COMMAND.COM in MS-DOS and Windows. It was written by Rex C. Conn and Tom Rawson and first released in 1989. Compared to the default, it has ...
", makes a copy of the matching lines in 4DOS.txt, sorts the lines, and writes them to the output file 4DOSsorted.txt: >find "4DOS" wikipedia.txt , tee 4DOS.txt , sort > 4DOSsorted.txt


PowerShell

Powershell is not suitable for binary and raw data, always treats the stream as text, and modifies the data as it is transferred. The syntax on PowerShell can be described as: tee FilePath InputObject tee -Variable InputObject *-InputObject Specifies the object input to the cmdlet. The parameter accepts variables that contain the objects and commands or expression that return the objects. *-FilePath Specifies the file where the cmdlet stores the object. The parameter accepts
wildcard character In software, a wildcard character is a kind of placeholder represented by a single character (computing), character, such as an asterisk (), which can be interpreted as a number of literal characters or an empty string. It is often used in file ...
s that resolve to a single file. *-Variable A reference to the input objects will be assigned to the specified variable. The command is implemented as a ReadOnly command alias that invokes the cmdlet named Microsoft.PowerShell.Utility\Tee-Object.


Examples

The following displays the standard output of command
ipconfig ipconfig (standing for "Internet Protocol configuration") is a console application program of some computer operating systems that displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) ...
in the
console window A terminal emulator, or terminal application, is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term ''terminal'' covers all remote termin ...
, and simultaneously saves a copy of it in the file OutputFile.txt. ipconfig , tee OutputFile.txt The following shows that the piped input for ''tee'' can be filtered and that ''tee'' is used to display that output, which is filtered again so that only processes owning more than 1000 handles are displayed, and writes the unfiltered output to the file ABC.txt. To display and save all running processes, filtered so that only programs starting with svc and owning more than 1000
handles A handle is a part of, or an attachment to, an object that allows it to be grasped and manipulated by hand. The design of each type of handle involves substantial ergonomic issues, even where these are dealt with intuitively or by following t ...
are output: Get-Process , Where-Object , Tee-Object ABC.txt , Where-Object


See also

* * *


References


Further reading

*


External links

*An introduction on Linux I/O Redirectio
"Linux I/O Redirection"
with tee

* * *
Delphi-Tee
-
Delphi (software) Delphi is a general-purpose programming language and a software product that uses the Delphi dialect of the Object Pascal programming language and provides an integrated development environment (IDE) for rapid application development of desktop, ...
OpenSource Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
implementation {{Use dmy dates, date=March 2018 Unix text processing utilities Unix SUS2008 utilities Plan 9 commands Inferno (operating system) commands ReactOS commands IBM i Qshell commands Windows administration Inter-process communication