bug-bash
[Top][All Lists]
Advanced

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

Re: bizarre trap behavior while reading a file


From: Greg Wooledge
Subject: Re: bizarre trap behavior while reading a file
Date: Tue, 29 Mar 2011 08:08:25 -0400
User-agent: Mutt/1.4.2.3i

On Tue, Mar 29, 2011 at 08:02:17AM -0400, Steven W. Orr wrote:
> Is there a difference between
> 
> while read line < file
> do
>     stuff
> done
> 
> vs
> 
> while read line
> do
>     stuff
> done < file

Yes.  It's a huge difference.  In the first one, the file is re-opened
by read every time through the loop, meaning you will keep reading the
first line of it over and over.  In the second one, the file is opened
once, and the read command gets the first line, then the second line, etc.



reply via email to

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