Newbie: read works incorrectly

Larry Hall (RFK Partners, Inc) lhall@rfk.com
Wed Nov 22 07:25:00 GMT 2000


At 10:05 AM 11/22/2000, Sylvain Petreolle wrote:

>--- schwarza@gdls.com a écrit : > 
> > The following statement:
> > 
> >       echo one two | while read line ; do
> >          printf '%s\r\n' $line
> >       done
> > 
> > generates
> > 
> >       one
> >       two
> > 
> > I would have expected
> > 
> >       one two
> > 
>The '\r\n' statement tells to printf to inser a new
>line, then remove it.


Actually I think Art's problem is that he's working from an improper 
supposition.  Just because read will put all the parameters into "line"
doesn't mean that "printf '%s\r\n' $line" will print both parameters.
Try "printf '%s %s\r\n' $line" to get what you expected. 



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list