Hi all this is my first post and I am having a little trouble solving this. I need to break a file up into many (many...many...many) smaller files based on the occurrence of the number "3" at the end of a line.
As an example of what I'm trying to accomplish:
a b c d 3
a b f g
t h g
j r i 0 3
a f t w
I wanted to end up outputting this:
1st file:
a b c d 3
a b f g
t h g
2nd file:
j r i 0 3
a f t w
At first I tried this script:
Code:
awk '/'3$'$/{d++}{print > d"extract.txt"}' $1
It worked perfectly, however the original input text file contained just over 960000 lines. As my first attempt did not contain a "close" statement Linux informed me that:
Quote:
awk: cannot open "1020extract.txt" for output (Too many open files)
However when I put the "close" in:
Code:
awk '/'3$'$/{d++}{print > d"extract.txt"}{close ( d"extract.txt" )}' $1
I only get the line preceding each occurrence of a line ending with "3"...I suppose it is closing the file before anything more can be written to it? Any ideas?