[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: |
Mon, 28 Mar 2011 08:11:02 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Mar 25, 2011 at 02:25:35PM -0700, tytus64 wrote:
> while read line
> do
> line_num=`expr $line_num + 1`
> echo $line_num: $line >> ./out.log
> done < $log_file
Although it's not directly related to your question, I feel obliged
to point out that you can increment a variable without forking an
external expr command:
line_num=$((line_num+1)) # POSIX sh compatible
or
((line_num++)) # Bash only
You only need expr when writing for the Bourne shell.
- Re: bizarre trap behavior while reading a file, (continued)
- 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, 2011/03/29
Re: bizarre trap behavior while reading a file,
Greg Wooledge <=