Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

tee - Linux command line tool to sent the output of a command also to a file

Date: 2007-05-22 00:00:00 -0400

tee command is very useful if you want to have the output of a command to the screen as usually, and also to a file, so you can review it later.

tee actually acts as a splitter, so you may have one input, and two or more outputs.

Usage

tee [options] file-list

The file-list is the list of files where the output is going to sent together with the standard output.

Options

--append -a
Appends output to existing files rather than overwriting them (Default is to overwrite)
--ignore-interupts -i
Causes tee not to respond to interrupts (Default is to respond to them)

Example

In the following example we will send the free output to the standard output and also to a file named free.txt

free | tee free.txt

             total       used       free     shared    buffers     cached
Mem:       1035852     632180     403672          0      32788     235148
-/+ buffers/cache:     364244     671608
Swap:      2650684          0    2650684
$ cat free.txt
             total       used       free     shared    buffers     cached
Mem:       1035852     632180     403672          0      32788     235148
-/+ buffers/cache:     364244     671608
Swap:      2650684          0    2650684

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.