• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

tee: command not found

by admin

The tee command reads the standard input, sends the output to the default output device (the CLI), and also copies the output to each specified file. This command enables you to verify the output of a command immediately as well as store that output in a file for later reference. Like xargs, tee typically accepts input from another command using the pipe operator.

When used with the -a option, tee appends the output to each output file instead of overwriting it.

Syntax

The general syntax of the tee command is:

# command [options] [arguments] | tee [options] {file names}

Let’s say you want to check the contents of a directory and also output those contents to a file to process later. You could issue separate commands to do this, or you can use the tee command like so:

# ls -l | tee listing.txt

If you encunter below error while running the tee command:

tee: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

tee Command Examples

1. Copy standard input to each file, and also to standard output:

# echo "example" | tee path/to/file

2. Append to the given files, do not overwrite:

# echo "example" | tee -a path/to/file

3. Print standard input to the terminal, and also pipe it into another program for further processing:

# echo "example" | tee /dev/tty | xargs printf "[%s]"

4. Create a directory called “example”, count the number of characters in “example” and write “example” to the terminal:

# echo "example" | tee >(xargs mkdir) >(wc -c)

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to list or install only security updates with dnf in CentOS/RHEL 8
  2. chown: command not found
  3. alias Command Examples in Linux
  4. How to enable additional scsi logging in CentOS/RHEL
  5. How To Remove Disk from a LVM Volume Group
  6. How to Create and Query a BTRFS File System
  7. pwck Command Examples in Linux
  8. How to run ssh on multiple ports
  9. Apache HTTP server – most commonly used configuration directives
  10. cpufreq-set Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright