Quote:
Originally Posted by
vgersh99
The "nawk-version" should write 2 lines/records per output file.
You can control the number of lines/records per file with 'FNR%2'
I didn't test it, but I don't think you can. It looks to me like that code ony works for FNR%n when n==2, since the result toggles between 1,0,1,0,1,0..., incrementing f as needed. If n==1, FNR%n==0 for all FNR and f always remains 0. When n>2, f will increment on each line read except when FNR%n==0, and the increments will be in steps of f+=1, f+=2, f+=3... f+=(n-1), f+=0, f+=1... creating a discontinous, ever increasing series.
Regards,
Alister
---------- Post updated at 07:50 PM ---------- Previous update was at 07:45 PM ----------
Of course, you can accomodate any n with a slight tweak to the code (initialize f to 1 and only increment f when FNR%n==0). If that's what you meant, disregard the noise.
Have a nice weekend, everyone,
Alister