Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to get log10() in awk script

4,150 views
Skip to first unread message

Tom Rudnick

unread,
Jul 1, 1997, 3:00:00 AM7/1/97
to

Given the awk builtin function log(), how can I get log10()?
Maybe I should be asking, how to convert bases between two logs.
My math fails me today, and I don't have my textbooks at work.

Thanks,
-Tom
----------------/----------------------------------------------
Tom Rudnick | USDA Natural Resources Conservation Service
Fort Collins,CO | t...@avatar.itc.nrcs.usda.gov (970) 282-1941
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Bob Stearns

unread,
Jul 1, 1997, 3:00:00 AM7/1/97
to Tom Rudnick
If my memory is not failing me, log_10(x) = log_e(x)/log_e(10);
Proof
log_10(x)*log_e(10) = log_e(x)
exp(log_10(x)*log_e(10)) = exp(log_e(x))
exp(log_e(10)*log_10(x)) = x
exp(log_e(10))^log_10(x) = x
10^log10(x) = x
x = x
--
Bob Stearns
University of Georgia
i...@groucho.dev.uga.edu
(706)542-5110

Junlei Li

unread,
Jul 2, 1997, 3:00:00 AM7/2/97
to

Hi, All, I am using an awk script to do some log analysis and
periodically, I get a "Awk: Record Too Long" error ... and abort.

Is there such a thing as a Max Awk Record Length? ... Is it adjustable?
...

Any help would be very appreciated ... Thanks.

Junlei

Rajeev Shankar

unread,
Jul 2, 1997, 3:00:00 AM7/2/97
to

Sometimes if the last record you are accessing does not
have a newline i.e "\n" then you may get this error.
Check all your records and see if they have a newline.

I am not sure about the restriction on the length of record.

Hope this helps

Rajeev

--
Rajeev Shankar

908-582-3017

Denis DUCAMP

unread,
Jul 3, 1997, 3:00:00 AM7/3/97
to

Junlei Li wrote:
>
> Hi, All, I am using an awk script to do some log analysis and
> periodically, I get a "Awk: Record Too Long" error ... and abort.
I found that kind of restrictions under HPUX (but I think that AIX and
others have the sames). In my experience under HPUX, awk generated a
core each time a line had more than 256 caracteres. I think that there's
a parameter to extend the max length of a line but I'm not sure because
some functions had bugs and then I used Gawk, see the manual.

Theoricaly, gawk (GNU awk) hasn't got such a restriction and is free.
Version 2.15p6 works fine. I haven't tested the 3.0.2 version yet.

>
> Is there such a thing as a Max Awk Record Length? ... Is it adjustable?
> ...
>
> Any help would be very appreciated ... Thanks.
>
> Junlei

Hope...

Denis.

Mark Katz

unread,
Jul 3, 1997, 3:00:00 AM7/3/97
to

In article <33BB74...@hotmail.com> ddu...@hotmail.com "Denis DUCAMP" writes:

>Junlei Li wrote:
>>
>> Hi, All, I am using an awk script to do some log analysis and
>> periodically, I get a "Awk: Record Too Long" error ... and abort.
>I found that kind of restrictions under HPUX (but I think that AIX and
>others have the sames). In my experience under HPUX, awk generated a
>core each time a line had more than 256 caracteres. I think that there's
>a parameter to extend the max length of a line but I'm not sure because
>some functions had bugs and then I used Gawk, see the manual.
>

Since you are using UNIX, you may wish to 'chop' it up into
fixed lengths of 'reasonable' length and then reassemble them
within the awk

fold -80 data-file | awk -f prog1.awk etc

Where prog1 contains something like this

if (NR % sub-lines-per-record != 0) {
line = line $0; next}
temp=line; $0=line; line=temp
You may have to split it into $1, $2 etc with a split statement

Note: this is unchecked !

Mark
--
Mark Katz
ISPC, London - Innovation in data-delivery tools
Tel: (44) 181-455 4665, Fax (44) 181-458 9554
** Visit our website on http://www.efiche.com/efiche **


Bruce R. McFarling

unread,
Jul 6, 1997, 3:00:00 AM7/6/97
to

On Thu, 3 Jul 1997, Denis DUCAMP wrote:

> Junlei Li wrote:
> >
> > Hi, All, I am using an awk script to do some log analysis and
> > periodically, I get a "Awk: Record Too Long" error ... and abort.
> I found that kind of restrictions under HPUX (but I think that AIX and
> others have the sames). In my experience under HPUX, awk generated a
> core each time a line had more than 256 caracteres. I think that there's
> a parameter to extend the max length of a line but I'm not sure because
> some functions had bugs and then I used Gawk, see the manual.
>

> Theoricaly, gawk (GNU awk) hasn't got such a restriction and is free.
> Version 2.15p6 works fine. I haven't tested the 3.0.2 version yet.
>
> >
> > Is there such a thing as a Max Awk Record Length? ... Is it adjustable?

From "Four AWK implementations for MS-DOS", 1989-1993, George
Theal.

Maxmimum Record Size:
DUFF_AWK 1024
GAWK 16384
MKS_AWK 2048
POLY_AWK 32000

16384 is pretty good for a record length. If your records are
longer than this, it seems awfully likely that your record seperator is
not what it should be, and you *should* get an error message to tell you
about it. 1024 (for example), or 256 is a lot less comfortable.

Virtually,

Bruce R. McFarling, Newcastle, NSW
ec...@cc.newcastle.edu.au


Shay

unread,
Jul 10, 1997, 3:00:00 AM7/10/97
to

what i usually do when i run up across a long record file is *try* to
switch between the record seperator and the field seperator, since the
number of records in most versions of awk is virtually unlimited.
ofcourse, this approach will only work with *simple* files.

On Wed, 02 Jul 1997 12:59:10 -0700, Junlei Li <tu1...@ibm.net> wrote:

>Hi, All, I am using an awk script to do some log analysis and
>periodically, I get a "Awk: Record Too Long" error ... and abort.
>

>Is there such a thing as a Max Awk Record Length? ... Is it adjustable?

Jennifer Cross

unread,
Jul 11, 1997, 3:00:00 AM7/11/97
to

Denis DUCAMP wrote:

>
> Junlei Li wrote:
> >
> > Hi, All, I am using an awk script to do some log analysis and
> > periodically, I get a "Awk: Record Too Long" error ... and abort.
as well as real record lenght limitations in your flavor
of awk, watch out for end of line convention problems
(processing unix files in msdos, or mac files in unix both
cause problems because of the incompatibilities of EOL)

>
> Theoricaly, gawk (GNU awk) hasn't got such a restriction and is free.
> Version 2.15p6 works fine. I haven't tested the 3.0.2 version yet.

gawk also handles far more fields per line and is faster

WARNING: Gawk version 3.0.1 - 3.0.2 have a per record memory leak
which makes them unsuitable for processing long files
this has been addressed/fixed in gawk 3.0.3

Jennifer Cross
busy body down under

0 new messages