Need immediate help with Awk! Thanks. 
Author Message
 Need immediate help with Awk! Thanks.

I'm typing the following command on a huge file:

awk '/^ISA/{x++}/^ISA/,/^IEA/{print>"o.edi"x}' JKFILE

This command looks in the file for ISA - IEA combinations and when it
finds it, it creates me a separate filename (o.edi)and also attaches to
the end of the file name a number.

Here's a piece of what the JKFILE would look like before I run awk on
it:

ISA*24567*444444*6666
BG*1*24567
IEA*2*24567
ISA*24668*55555*6666
BG*1*44556
IEA*3*56666

As you can see, there's two ISA-IEA groups in here and so after I run
the awk command on it, awk creates me two files called o.edi1 and
o.edi2.

Well, it's been working, but this time I have a very big file and when
I run the above awk command on it, I get some sort of error stating
that there's a maximum of 506 files that it can create.  I had no idea
that there was a limit to the amount of files that it could create for
me.  To be honest with you, there's probably 1500 individual ISA - IEA
combinations in the file.  Do you guys know of any ways to bypass this
problem?  It really screwed me today and I need help badly.  I'm all
for modifying the above awk command or using an entirely different
command to do the same thing.  THANKS.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 17 Feb 2003 22:50:02 GMT  
 Need immediate help with Awk! Thanks.

Quote:

> I'm typing the following command on a huge file:

> awk '/^ISA/{x++}/^ISA/,/^IEA/{print>"o.edi"x}' JKFILE

> I run the above awk command on it, I get some sort of error stating
> that there's a maximum of 506 files that it can create.

With luck, the error is the number of open files it can handle.

Try closing the previous file when you've completed outputting to it.

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 17 Feb 2003 23:04:31 GMT  
 Need immediate help with Awk! Thanks.
I don't have a copy of awk to hand, but it might help to close
the files after you've finished with them, e.g.:

awk '/^ISA/{x++;if(x>1)close("o.edi"x-1)}/^ISA/,/^IEA/{print>"o.edi"x}' JKFILE

I'm not sure if this will work or not.

Alternatively use gawk.

Tristan.

Quote:

> I'm typing the following command on a huge file:

> awk '/^ISA/{x++}/^ISA/,/^IEA/{print>"o.edi"x}' JKFILE

> This command looks in the file for ISA - IEA combinations and when it
> finds it, it creates me a separate filename (o.edi)and also attaches to
> the end of the file name a number.

> Here's a piece of what the JKFILE would look like before I run awk on
> it:

> ISA*24567*444444*6666
> BG*1*24567
> IEA*2*24567
> ISA*24668*55555*6666
> BG*1*44556
> IEA*3*56666

> As you can see, there's two ISA-IEA groups in here and so after I run
> the awk command on it, awk creates me two files called o.edi1 and
> o.edi2.

> Well, it's been working, but this time I have a very big file and when
> I run the above awk command on it, I get some sort of error stating
> that there's a maximum of 506 files that it can create.  I had no idea
> that there was a limit to the amount of files that it could create for
> me.  To be honest with you, there's probably 1500 individual ISA - IEA
> combinations in the file.  Do you guys know of any ways to bypass this
> problem?  It really screwed me today and I need help badly.  I'm all
> for modifying the above awk command or using an entirely different
> command to do the same thing.  THANKS.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Tue, 18 Feb 2003 00:42:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. THANKS: Help passing command line parameters to awk script

2. Need immediate help regarding Error code 5

3. Thank you & need help with something else

4. Need Help : a basic scheme problem ( thanks in advancd )

5. helps needed... thanks

6. Need HELP on wirtting the data to the file in Fortran 90 ...THANKS

7. Problem: Need help!! - thanks

8. need help using AWK

9. Need help with sed or awk !!

10. Need a bit of awk help, very new to it

11. newbie needs help with multiple expressions in awk

12. Need some help with awk addition

 

 
Powered by phpBB® Forum Software