[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.
- Re: bizarre trap behavior while reading a file, (continued)
- Re: bizarre trap behavior while reading a file, tytus64, 2011/03/28
- Re: bizarre trap behavior while reading a file, Greg Wooledge, 2011/03/28
- Re: bizarre trap behavior while reading a file, Chet Ramey, 2011/03/28
- Re: bizarre trap behavior while reading a file, tytus64, 2011/03/28
- Re: bizarre trap behavior while reading a file, Chet Ramey, 2011/03/28
- Re: bizarre trap behavior while reading a file, tytus64, 2011/03/28
- Re: bizarre trap behavior while reading a file, Chet Ramey, 2011/03/28
- Re: bizarre trap behavior while reading a file, tytus64, 2011/03/29
- Re: bizarre trap behavior while reading a file, Mart Frauenlob, 2011/03/29
- Re: bizarre trap behavior while reading a file, Steven W. Orr, 2011/03/29
- Re: bizarre trap behavior while reading a file,
Greg Wooledge <=
Re: bizarre trap behavior while reading a file, Greg Wooledge, 2011/03/28