bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why `echo -n hello | while read v; do echo $v; done' prints nothing?


From: William Park
Subject: Re: Why `echo -n hello | while read v; do echo $v; done' prints nothing?
Date: Thu, 2 Dec 2010 14:04:44 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Dec 02, 2010 at 11:33:24AM -0500, Greg Wooledge wrote:
> On Thu, Dec 02, 2010 at 09:29:29AM -0700, Eric Blake wrote:
> > On 12/02/2010 04:04 AM, Clark J. Wang wrote:
> > > Following command also prints nothing, confused :(
> > > 
> > > for ((i = 0; i < 10; ++i)); do echo -n " $i"; done | while read v; do echo
> > > $v; done
> > 
> > http://www.faqs.org/faqs/unix-faq/shell/bash/
> > FAQ E4.
> 
> That was my first thought as well, upon first glance.  But that's not
> the actual problem here.  It's the lack of newline causing read to return
> 'failure' even though it does read the input.

Yeah, it has bitten me too many times.  I keep forgetting it though.

-- 
William



reply via email to

[Prev in Thread] Current Thread [Next in Thread]