Quote:
Originally Posted by
tomas
grep for #fruit then get a count with wc -l. Your source is structured with 5 lines for each entry so divide the number of #fruit entries found by 2 then multiply that by 5 using bc. You can then use the split -l command to make your two files using those results. I would add something to make sure none of the lines go missing.
Thanks!
I think this is close to a way to do it. How can x5 help me to find correct place to cut?
Something like this might work:
- Filter out heading or trailing newlines to assure the count will be correct.
- Grep for "#fruit" and pipe it through "wc -l" to get amount of "#fruit" - elements.
- If number is even number I can split in middle
"wc -l"/2.
- If number is odd I can split at:
("wc -l"/2)+3 lines
And then I probably have to adjust 1 lines up or down to get the split exact.
Hmm...if this works I need to find out if a number is odd or even.
Borgeh