The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2009
fracken_toaster fracken_toaster is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 3
tee

Someone recently advised me to use the tee command to write to standard out.

Why would you pipe your commands to
tee -a <filename>
rather than just using
>> <filename>
?

For example:

date|tee -a myfile

seems to be the same as

date >> myfile

Is there a benefit to using tee that I'm not seeing?

Thanks,

Darin
  #2 (permalink)  
Old 09-28-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,814
When you need to write a log and put the same data to the tty, then tee is useful.

Plus

Code:
date > t.lis

does not write anything to the tty. All stdout output goes into the file.

A best use of tee is:

Code:
command 2&>1 | tee -a somelog.file

To capture both errors and normal output. This way the person running the script sees what happened. Then support has a log file to refer to as well.
  #3 (permalink)  
Old 09-28-2009
fracken_toaster fracken_toaster is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 3
ok. But can't you do the same thing with

Code:
command >> somelog.file 2/&1

?
  #4 (permalink)  
Old 09-28-2009
scottn scottn is online now Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,135
I think you missed the main point of Jim's statement:

Quote:
When you need to write a log and put the same data to the tty, then tee is useful.
Tee will write to the file and copy the output to the screen.

If you want to write to the file, and not see the output then don't use tee, otherwise do.
  #5 (permalink)  
Old 09-28-2009
fracken_toaster fracken_toaster is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 3
Ok. Thanks. That helps me.
  #6 (permalink)  
Old 09-30-2009
shantanuo shantanuo is offline
Registered User
  
 

Join Date: Aug 2008
Location: Mumbai
Posts: 79
mysql -uroot -pPassWord --tee='/root/myquery.txt'

I do always use tee while accessing Mysql database. This helps me to check the output of a sql command when I can not browse the earlier pages using "Page Up".
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0