So group 1 had all 10 values, group 2 (numbers 1,33,32,13) had only 4 values hence, padding of 6 more newlines to make it 10; group 3 (13,23,44,11,67,87) has only 6 values so padd it with 4 newlines to make it 10, etc.
Next I want to collect all these values in an array including the empty lines as a null array element.
These numbers are extracted from another file which has groups of 10. All I want is to pad the file which has missing entries, with newlines. Will it be easier if I modify the original file as follows:
So now I have inserted a newline between individual groups.Group1 has all 10 entries, group 2 has only 4 entries (that means I will have to add 6 newlines), group 3 has 6 entries (so I will have to add 4 lines) and so on.
while read L # reads on lie from input and ssign it to L
do
[ -n "$L" ] && { ((i++)); echo $L; continue; }
# if L is not empty then increment i, output L, next iteration of the loop
until [ $i -eq 10 ] # doesn't need explanation
do ((i++)); echo
done
i=0 # reset i for the next 10 count
done < infile
If you want to see what happens during the running of the script, you can