Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows
Last updated: Jul 29, 2021

How to use a bash tee command

Here you will find out:

  • what a bash tee command is
  • how to use the tee command
  • when DiskInternals can help you

Are you ready? Let's read!

What is a bash tee command?

The Linux tee command is a command-line utility used to read standard inputs and write to standard outputs and other files simultaneously. This command is used alongside other commands. The name “tee” comes from T-splitter, a term used in plumbing. With the bash tee command, you can simultaneously display and save a file you’re working on.

The syntax and options of the tee command

Here’s the syntax of the bash tee command:

The syntax of the bash tee command

Explanation

Copy standard input to each FILE, and also to standard output.

Options:

To view all options of the “tee” command, type “tee –help”. However, the following options are the most commonly used.

-a (--append) – append to the indicated files and don’t overwrite the files

-i (--ignore-interrupts) - ignore interrupt signals

Using the tee command

The tee command is used mainly to display standard output (stdout) of a command and copy it to an indicated file.

Example:

Using the tee command

The above command will run and display the desired output on the terminal, as well as write the output to the “linux.txt” file at the same time.

This is the basic syntax of the bash tee command.

How to append to a file

Without using the -a (--append) variable, the tee command will overwrite the content of the specified file. Here is how to use the -a (--append) variable with the tee command:

the -a variable with the tee command

The command above will append the result from pinging diskinternals.com to the linux.txt file, instead of overwriting the content.

How to write to multiple files

Just the way you called the first file, you can call multiple files, too:

How to write to multiple files

Example:

To write to multiple files

How to ignore the interrupt signal

When you press CTRL+C during the execution of a command, you'll likely get the interrupt signal (SIGINT). However, to ignore this signal when running the tee command, use -I (--ignore interrupts).

Example:

How to ignore the interrupt signal

Using tee to write to a privileged file

You can write to a privileged file using the bash tee command. The tee command is used for piping to sudo permissions.

When you have a root file, obviously you’ll need permissions to write/append to that root file. However, when you use the tee command, it elevates the permissions and lets you copy to a root file.

Examples:

To write to a privileged file

This may return:

Using tee to write to a privileged file

Using tee:

Using tee example

You can open Linux files with Linux Reader

Let’s say you’re using a dual-boot PC and you’re booted to Windows, but need to access some files saved on your Linux partition. You don’t have to shut down and reboot to Linux for this purpose. Using DiskInternals Linux Reader, you can read and access Linux files on Windows. DiskInternals Linux Reader is user-friendly and has a couple of handy features you’ll love to use. It is an advanced PC utility, available for free.

Related articles

FREE DOWNLOADVer 4.21, WinUpgrade to PROFrom $29.95

Please rate this article.