[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: |
Greg Wooledge |
Subject: |
Re: Why `echo -n hello | while read v; do echo $v; done' prints nothing? |
Date: |
Thu, 2 Dec 2010 11:33:24 -0500 |
User-agent: |
Mutt/1.4.2.3i |
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.