> -----Original Message-----
> From: Raoul Golan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 7 January 2000 16:06
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]; 'Shrestha'
> Subject: Re: [SLUG] Re: addition using script file
>
>
>
> Uhmmm, the awk script you listed will only add the second fields
> of lines 3 and 6, not the second fields of lines 3 *TO* 6.
> Admittedly,
> Shre's question was rather ambiguous.
You're right - I though the request was to add line 3 to line 6, but I see
that it could also be interpreted as adding lines 3 through 6.
> You may need to change that to:
..deleted
Hmmm... the following is more concise.
#!/bin/awk -f
(NR >= 3 && NR <=6) {
num += $2;
}
END {
print num;
}
> Or even better :) :), change that to:
>
> #!/usr/bin/perl -w
>
> while (<STDIN>) {
> $i++;
> next if $i < 3;
> last if $i > 6;
>
> $total += (split)[1];
> }
> print "$total\n";
Yuck! Perl - the Swiss Army chainsaw of Unix tools. =8^)
Too verbose for the simple stuff, not quite enough for the real hard stuff.
But very, very good for CGI scripts!
Regards,
Craig Southeren
-------------------------------------------
Equivalence - Home of FireDoor, MibMaster & PhonePatch
For Open Source H.323 - see http://www.openh323.org
Email: [EMAIL PROTECTED]
Web: http://www.equival.com.au
Fax: +61 2 4368 1395 Voice: +61 2 4368 2118
-----------------------------------------------------
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text