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

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Unix command and scripts » tee command in Unix

tee command in Unix

July 13, 2020 by techgoeasy Leave a Comment

In this article, we will be discussing the use cases of the tee  Unix command with examples.

Table of Contents

  • tee command
    • How to use tee command
    • -a option with tee command
    • How to use tee to write to multiple files

tee command

tee   – Used in the middle of a pipeline, this command allows you to both redirect output to a file, and pass it to further commands in the pipeline.

How to use tee command

 Examples: $check_patch_logs.ksh | tee check.log| more   

The output of check_patch_logs.ksh is stored in the filecheck.log, and also pass it to more to display it one screen at a time.

-a option with tee command

By default, the tee command overwrites the file.

ls | tee x.txt

The above command will overwrite the file x.txt if it exists

You can instruct tee command to append to the file using the option –a

ls | tee -a x.txt

Now this will create a new file x.txt if it does not exists, if it exists, it will append to it

How to use tee to write to multiple files

We just need to specify the files name

ls | tee x.txt x1.txt x2.txt

it will store the output of ls in all these files.

Also Read
awk command : Awk command in Unix or Linux is a powerful command for processing text. Learn about awk syntax, records, fields, line Separator with examples of awk in Unix
sed command : sed command is a Stream Editor – works as a filter processing  input line by line And here are 32 Useful sed command examples in Linux/Unix
grep command in Unix : Grep command Means – globally search regular expression.grep command in unix is used for searching text, regular expression across multiple files
windows grep equivalent: windows grep equivalent to search text: Find | findstr | power select-string. Detailed explanation with lots of examples for easy understanding
tr command in Unix: Check out about tee command in Unix, what options are available, how to append file using tee command, how to write to multiple files
gzip and gunzip command in Linux

Filed Under: Unix command and scripts

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • How to use sed replace string in file
  • Password Version in oracle
  • How to login as user without changing the password in Oracle database(alter user identified by values)
  • How to check encrypted tablespace in the Database
  • How To Export -Import TDE Master Encryption Key

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us