[ale] Awk question

Lightner, Jeff JLightner at water.com
Tue Feb 7 09:07:09 EST 2012


Any time I need to do floating point in a script I pipe it to “bc –l”.   Maybe not the most elegant way to do things but it works.






________________________________
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of Randy Ramsdell
Sent: Tuesday, February 07, 2012 8:28 AM
To: ale at ale.org
Subject: Re: [ale] Awk question

Haven't had time to work on this. Spent much time on it and had to move on. Thanks for the replies so far. Now I just have to think 'floating point' but will at least get the formula down. I was simply trying to do this all in awk instead of the pipe everything to another program to handle the respective pieces.

On 02/07/2012 07:31 AM, Richard Bronosky wrote:

You are right. That is why I sent my reply with the correct solution. I was thinking that my emails were not getting to the list until Jim replied to a post I made on another thread.
On Feb 6, 2012 2:55 PM, "Geoffrey Myers" <lists at serioustechnology.com<mailto:lists at serioustechnology.com>> wrote:
Erik Mathis wrote:
> awk '{sum+=$2} END {print sum}' filename
> 310
> awk '{subt-=$2} END {print subt}' filename
> -310

Seems to me that will total all the records.  The OP only want's the
last two as I recall.

>
> Stolen and hacked from http://www.commandlinefu.com
>
> -Erik-
>
> On Fri, Feb 3, 2012 at 1:51 PM, Randy Ramsdell <rramsdell at activedg.com<mailto:rramsdell at activedg.com>> wrote:
>> I need to parse a file and then subtract next to last line field $2
>> from the last line field $2 using awk and then convert this number to a
>> percent.
>>
>> Data:
>>
>> $date 100
>> $date 103
>> $date 107
>>
>> So ... ( 107 - 103 ) / 103 ...
>>
>> Clues?
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org<mailto:Ale at ale.org>
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
> _______________________________________________
> Ale mailing list
> Ale at ale.org<mailto:Ale at ale.org>
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo


--
Until later, Geoffrey

"I predict future happiness for America if they can prevent
the government from wasting the labors of the people under
the pretense of taking care of them."
- Thomas Jefferson
_______________________________________________
Ale mailing list
Ale at ale.org<mailto:Ale at ale.org>
http://mail.ale.org/mailman/listinfo/ale
See JOBS, ANNOUNCE and SCHOOLS lists at
http://mail.ale.org/mailman/listinfo





_______________________________________________

Ale mailing list

Ale at ale.org<mailto:Ale at ale.org>

http://mail.ale.org/mailman/listinfo/ale

See JOBS, ANNOUNCE and SCHOOLS lists at

http://mail.ale.org/mailman/listinfo






Athena®, Created for the Cause™

Making a Difference in the Fight Against Breast Cancer



---------------------------------
CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
----------------------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20120207/0638553c/attachment.html 


More information about the Ale mailing list