delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/13/11:50:33

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <5.1.0.14.2.20020313084036.00abc1c8@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
X-Mailer: QUALCOMM Windows Eudora Version 5.1
Date: Wed, 13 Mar 2002 08:50:28 -0800
To: "Robert Mark Bram" <relaxedrob AT no DOT spam DOT optushome DOT com DOT au>,
cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: IO Redirection
In-Reply-To: <a6nb61$jon$1@main.gmane.org>
References: <Pine DOT GSO DOT 4 DOT 44 DOT 0203131135120 DOT 1388-100000 AT domino DOT informatik DOT uni-kl DOT de>
Mime-Version: 1.0

Robert,

[ Yes, Bjoern, this is OT for the Cygwin list as it's all about shell usage and not at all Cygwin specific. ]


You're using BASH, Robert. Except for the simple ">" and ">>" redirection, it's syntax is different from that of TCSH. Bjoern's answer was for TCSH.

I'm a BASH user, so I'll answer for that shell.

# Simple redirection of standard output only, overwriting existing file, if any:
% echo "foo is bar" >fbfile

# Appending redirection
% echo "foo is more bar" >>fbfile

# Redirect standard error only
% command-that-generates-error-output arg1 arg2 2>error-output

# Redirect standard output and standard error separately
% command arg >stdout 2>stderr

# Merge standard error with standard output
#   Order of redirection operators IS significant
% command arg1 arg2 >merged-output 2>&1


All the output redirections can be doubled for appending, but that does not apply to the descriptor merging forms (e.g., 2>&1, which means merge descriptor 2 with the current descriptor 1 and works for any number greater than 0).

Good luck. Get a good tutorial that covers BASH.

Randall Schulz
Mountain View, CA USA


At 02:54 2002-03-13, Robert Mark Bram wrote:
>Thanks for the reply!
>
>> > How do I append error output?
>> > How do I append error and standard output?
>>
>>  Just as you have written?
>>  ">>" appends, ">" write to a new file, independend of the file
>>  or source selected. That is,  "&>>file" appends both.
>>
>>  Why is that not obvious ?
>
>This is why:
>
>Robert Mark Bram AT DIJONG ~
>$ ls
>errors  script1  script2  temp
>
>Robert Mark Bram AT DIJONG ~
>$ ls &>> temp
>bash: syntax error near unexpected token `&>>'
>
>Robert Mark Bram AT DIJONG ~
>$
>
>Rob


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019