1827251 Members
3123 Online
109716 Solutions
New Discussion

Re: awk script

 

awk script

Hi,
I have a file and each line is greater than 3000 bytes. I have to search the word and count and print it. But the problem with awk I cannot do becuase of its 3000 bytes restriction.
Is someone have any alternative inputs.
Thanks
Zafar
Win/Win
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: awk script

Hi:

Your best bet is to download GNU's versions of awk - 'gawk'. It is available from any of the HP-UX Porting Centres and has dynamically allocated maximum record size that can be set from the command line.

Clay
If it ain't broke, I can fix that.

Re: awk script

If was thinking of gawk; but I am not sure about that. If you the link for gawk download, I'll appreciate it.
Win/Win
harry d brown jr
Honored Contributor

Re: awk script

THis site shows a benchmark of quite a few programs, and you can download the source code.

http://www.bagley.org/~doug/shootout/bench/wordfreq/
Live Free or Die
Wodisch
Honored Contributor

Re: awk script

Hello Zafar,

well, you can still substitute something in those long
lines with a NEWLINE using something like "tr(1)" and
then pipe that to "awk(1)" to find and count it:

tr "\040\t" "\n" YOUR-FILE-HERE | awk ...

This example would split your file at every space and
tab into a new line, hence getting around the line length
restriction...

Of course, you max add more "split-characters" into the
first parameter of "tr(1)"!

HTH,
Wodisch
Patrick Wallek
Honored Contributor

Re: awk script

R. Allan Hicks
Trusted Contributor

Re: awk script

I may be missing the point of the question....

Is all you want the word count? If so, will wc work?
"Only he who attempts the absurd is capable of achieving the impossible
harry d brown jr
Honored Contributor

Re: awk script

I think Zafar is looking for something that will find a word and count the number of times it shows up.
Live Free or Die