Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 21 Nov 2014, 15:10
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
Redirection with 'tee' - having your cake and eating it too.
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count_1  
Author Message

Joined: 21 Sep 2010
Posts: 448
Location: Oslo, Norway

PostPosted: Sat 09 Feb 2013, 13:38    Post_subject:  Redirection with 'tee' - having your cake and eating it too.  

There is a very useful command named 'tee', that I don't see mentioned very often. I have gathered some info here.
Unix/Linux borrows an idea here from the plumbing trade. This is a redirection operator, but with a difference. Like the plumber's 'tee', it permits 'siphoning off' to a file the output of a command or commands within a pipe, but without affecting the result. This is useful for printing an ongoing process to a file or paper, perhaps to keep track of it for debugging purposes.

The `tee' command copies standard input to standard output and also to any files given as arguments. This is useful when you want not only to send some data down a pipe, but also to save a copy.

Synopsis: tee [OPTION]... [FILE]...

cat listfile* | sort | tee check.file | uniq > result.file

Here, the file 'check.file' contains the concatenated sorted "listfiles", before the duplicate lines are removed by uniq, and the result of that operation is sent to 'result.file'.

ls /root | tee my_directories.txt

Lists the files (displays the output on the screen) and also sends the output to a file: 'my_directories.txt'. (puppy specific - the original would be /home/username instead of /root)

You can also write the output to multiple files as shown below.
ls | tee file1 file2 file3

  • If a file being written to does not already exist, it is created.
  • By default tee command overwrites the file.You can instruct the 'tee' command to append to the file using the option –a as shown below.
    `-a' `--append' Append standard input to the given files rather than overwriting them.
    ]ls | tee –a file


True freedom is a live Puppy on a multisession CD/DVD.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count_1  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0397s ][ Queries: 11 (0.0032s) ][ GZIP on ]