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

On Thu, Dec 02, 2010 at 07:04:57PM +0800, 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

The output from the first command in the pipeline does not end with a
newline.  Therefore, 'read' in the second command returns 'failure'
(non-zero) when it reads the first line of input, and your loop never
iterates.



reply via email to

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