Mail Archives: cygwin/2002/03/13/11:50:33
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 -