|
Home > Archive > Unix Shell > February 2007 > tee command
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| harpreet.saluja@gmail.com 2007-02-27, 7:21 am |
| Hi,
I was seeing the usage of tee command on web and I found the following
example:
$ some_command |& tee command.log
Can anyone explain me why do we need the "&" after the pipe ?
Thanks.
Harpreet
| |
| Stachu 'Dozzie' K. 2007-02-27, 7:21 am |
| On 27.02.2007, harpreet.saluja@gmail.com <harpreet.saluja@gmail.com> wrote:
> Hi,
>
> I was seeing the usage of tee command on web and I found the following
> example:
>
> $ some_command |& tee command.log
>
> Can anyone explain me why do we need the "&" after the pipe ?
"... |& ..." is a zshellism. It's shortcut for "... 2>&1 | ...". It
certainly won't work under bash or ksh.
--
<Kosma> Niektórzy lubi± dozziego...
<Kosma> Oczywi¶cie szanujemy ich.
Stanislaw Klekot
| |
| Bruce Barnett 2007-02-27, 7:21 am |
| harpreet.saluja@gmail.com writes:
> Hi,
>
> I was seeing the usage of tee command on web and I found the following
> example:
>
> $ some_command |& tee command.log
>
> Can anyone explain me why do we need the "&" after the pipe ?
That's CSH. |& merges stdout and stderr into a single stream.
This way all output and all error messages are sent to command.log as
well as the terminal.
--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
| |
| harpreet.saluja@gmail.com 2007-02-28, 1:22 am |
| Thanks Bruce, I am using CSH and your answer seems to be in accordance
with what I observed. One more question, if you want to merge the
stdout and stderr messages on other sheels like bash, what command do
you use ?
On Feb 27, 5:40 pm, Bruce Barnett
<spamhater123+U070227073...@grymoire.com> wrote:
> harpreet.sal...@gmail.com writes:
>
>
>
>
> That's CSH. |& merges stdout and stderr into a single stream.
>
> This way all output and all error messages are sent to command.log as
> well as the terminal.
>
> --
> Sending unsolicited commercial e-mail to this account incurs a fee of
> $500 per message, and acknowledges the legality of this contract.
| |
| Chris F.A. Johnson 2007-02-28, 1:22 am |
| On 2007-02-28, harpreet.saluja@gmail.com wrote:
>
> On Feb 27, 5:40 pm, Bruce Barnett
><spamhater123+U070227073...@grymoire.com> wrote:
[please do not top post]
[vbcol=seagreen]
> Thanks Bruce, I am using CSH and your answer seems to be in accordance
> with what I observed. One more question, if you want to merge the
> stdout and stderr messages on other sheels like bash, what command do
> you use ?
In all Bourne-type shells:
command ARGS > /path/to/file 2>&1
Bash has a shorthand version, but there's no good reason to use it
and make the script less portable.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
|
|
|
|
|