I have a large file with a sample as below
A222, 00000, 555
A222, 00100, 555
A222, 00200, 555
A222, 00300, 555
A222, 00000, 555
A222, 00100, 555
A222, 00000, 555
A222, 00200, 555
It's a sample file which has order header(00000) and related order details(00100, 00200 etc.) I want to split file with around 40000 lines each such that each file has order headers and order details together.
I used GNU parallel
to achieve the split of 40000 lines, But I am not able to achieve the split to satisfy the condition that makes sure that the Order Header and its related order details are all together in a line making sure that each file has around 40000 lines each
For the above sample file, if I have to split with around 5 lines each, I would use the below
parallel --pipe -N5 'cat > sample_{#}.txt' <sample.txt
But that would give me
sample1.txt
A222, 00000, 555
A222, 00100, 555
A222, 00200, 555
A222, 00300, 555
A222, 00000, 555
sample2.txt
A222, 00100, 555
A222, 00000, 555
A222, 00200, 555
It would have 2nd Order header in the first file, and its related order details in the second one.
The desired should be
sample1.txt
A222, 00000, 555
A222, 00100, 555
A222, 00200, 555
A222, 00300, 555
sample2.txt
A222, 00000, 555
A222, 00100, 555
A222, 00000, 555
A222, 00200, 555