IO Redirection
Randall R Schulz
rrschulz@cris.com
Wed Mar 13 09:10:00 GMT 2002
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@DIJONG ~
>$ ls
>errors script1 script2 temp
>>Robert Mark Bram@DIJONG ~
>$ ls &>> temp
>bash: syntax error near unexpected token `&>>'
>>Robert Mark Bram@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/
More information about the Cygwin
mailing list