Talk:Tee (command)

Latest comment: 11 years ago by ReubenGarrett in topic Is the sudo Example accurate?

Utility

edit

Why would anyone ever use this command? Honest question - Surely it wouldn't be as widely available as it is if it weren't of some value. However, I find myself scratching my head till my skull shows to imagine why a person would need this command. Anyone able to provide a real-world example of where this command is useful? Mrzaius 18:07, 24 April 2006 (UTC)Reply

See Pipeline (Unix) for a real world example. Actually a tee is not very useful without a pipe. Pipes are started in Unix but every major OS supports it today: Windows, Linux, Mac OS, Unix. —Preceding unsigned comment added by 203.200.143.97 (talk) 21:57, 14 January 2008 (UTC)Reply
Ok. Say I am remotely running a long database update. I want to know how it is running, in case there are error messages or problems, so that I may stop the update. This is how many programs are run, with the output to the foreground. But if the update goes on a long time, I may have to leave the computer, and I want to review the output later. The only way to achieve this, is to tee the output to a log file. --Unixguy 14:43, 26 April 2006 (UTC)Reply
It duplicates the input stream (not only for display) so one can have output logging to one specific file for a program call plus output logging to an overlaying script logfile or even piping it to a second command. It does that in realtime (similar to the "tail" command) so it cannot (always) be replaced by writing output to a logfile and then grabbing that logfile for further processing. Very useful for unattended long running batch processing --Volker 14:49 20 Oct 2006 (CET)
if you really leave "the place", where the command is running, start it using nohup, rename nohup.out to whatever you like and run tail -f on it --johayek (talk) 09:58, 11 November 2009 (UTC)Reply

Wikipedia is not an instruction manual

edit

Why not? What better place to find instructions?? DGerman (talk) 17:17, 4 January 2008 (UTC)Reply

If you delete this article, please delete this one too: tee (WPS). As an alternative you can merge both articles into one.

or rather, if you delete this article, delete 90% of all computer related articles. i'm removing the delete notice. —Preceding unsigned comment added by 69.125.110.223 (talk) 14:47, 13 December 2007 (UTC)Reply

I think merging both articles is a good idea. Some of these computer related articles already cover more than one implementation of a particular command if it is available on more than one platform or shell:

Is the sudo Example accurate?

edit
"This example shows tee being used to bypass an inherent limitation in the sudo command. sudo is unable to pipe the standard output to a file. By dumping its stdout stream into /dev/null, we also suppress the mirrored output in the console."

hm. sudo isn't "unable" to > to a file, it's just that bash (or whatever you use) interprets the > and it doesn't get passed on to sudo.

Which is just another way of saying that sudo is unable to "sudo" piping, it must use a separate program (such as tee or sh) to achieve the effect indirectly, like you demonstrate below by explicitly specifying the helper program give root privilege to. —Preceding unsigned comment added by 82.116.252.2 (talk) 08:32, 26 November 2009 (UTC)Reply

some command | sudo 'sh -c "cat > root_owned_file"' is equivalent to some command | sudo tee root_owned_file >/dev/null, for example. S. Morrow (talk) 19:53, 11 January 2009 (UTC)Reply

i agree that the sudo section should be clarified to explain that usage of tee with sudo is a convenience to to avoid escaping/quoting shell constructs (such as redirects). that was confusing to me when i first read it ("what does sudo have to do with supporting redirects?"). RubyTuesdayDONO (talk) 04:11, 15 April 2013 (UTC)Reply

Buffer problem

edit

The tee command often fails to produce desired results. Normal screen display is usually immediate. But the screen display output of the tee command is buffered, so it is not immediate -- it may be delayed by hours! The commands stdbuf, unbuffer, and unbuffered are rumored to help, but may not be available. The script command seems to be an answer, though not a great one. Please improve the article with details about this issue.

  • coderrr.wordpress.com/2008/12/20/automatically-flushing-redirected-or-piped-stdout/
  • www.aboutlinux.info/2005/11/script-command-to-record-everything.html
  • linux.about.com/library/cmd/blcmdl1_script.htm

-96.233.20.116 (talk) 21:57, 24 June 2012 (UTC)Reply