I would like to limit all files to be of the same fixed length but the last item can be any variable size but not more than 557.
This means that the file amount can be more than determined by the flag -n
of the command split
.
Code 1 (ok)
$ seq -w 1 1671 > /tmp/k && gsplit -n15 /tmp/k && wc -c xaa && wc -c xao
557 xaa
557 xao
where xaa is the first file of the sequence, while xao the last one. I increase the sequence by one unit but it causes 5 unit increase (557->562) in the last file xao which I do not understand:
$ seq -w 1 1672 > /tmp/k && gsplit -n15 /tmp/k && wc -c xaa && wc -c xao
557 xaa
562 xao
Why does the increase of one-unit in sequence increase the last item (xao) by 5 units?
Code 2
$ seq -w 1 1671 | gsed ':a;N;$!ba;s/\n//g' > /tmp/k && gsplit -n15 /tmp/k&& wc -c xaa && wc -c xao
445 xaa
455 xao
$ seq -w 1 1672 | gsed ':a;N;$!ba;s/\n//g' > /tmp/k && gsplit -n15 /tmp/k&& wc -c xaa && wc -c xao
445 xaa
459 xao
so increasing the whole length by one sequence (4 characters) leads to 4 character increase (455 -> 459), in contrast to the first code where increase is 5 characters.
Code 3
Let's now keep each unit of sequence fixed to 4 characters by seq -w 0 0.0001 1 | gsed 's/\.//g'
:
$ seq -w 0 0.0001 1 | gsed 's/\.//g' | gsed ':a;N;$!ba;s/\n//g' > /tmp/k && gsplit -n15 /tmp/k&& wc -c xaa && wc -c xao
3333 xaa
3344 xao
$ seq -w 0 0.0001 1.0001 | gsed 's/\.//g' | gsed ':a;N;$!ba;s/\n//g' > /tmp/k && gsplit -n15 /tmp/k&& wc -c xaa && wc -c xao
3334 xaa
3335 xao
so increasing the sequence by one characters increases xaa by unit but decreases xao by 9 units. This behavior is what I do not keep so logical.
How can you limit the sequence length first, for instance to be fixed at 557 and later determine the amount of files of successful files?