You can use the following single-line awk:
awk '{b=a;a=$1;while(a>(b++)+1){print(b+1)," 0 0 0 0 0"}}1' input.file
Tested with input here-document:
awk '{b=a;a=$1;while(a>(b++)+1){print(b+1)," 0 0 0 0 0"}}1' <<EOF 1 1 2 3 4 5 2 1 2 3 4 5 5 1 2 3 4 5 8 1 2 3 4 5 9 1 2 3 4 5 10 1 2 3 4 5 11 1 2 3 4 5 EOF
The output is as follows:
1 1 2 3 4 5 2 1 2 3 4 5 3 0 0 0 0 0 4 0 0 0 0 0 5 1 2 3 4 5 6 0 0 0 0 0 7 0 0 0 0 0 8 1 2 3 4 5 9 1 2 3 4 5 10 1 2 3 4 5 11 1 2 3 4 5
Explanation:
On each line of input b , the value a , where a is the value of the first column. Due to the order in which b and a initialized, b can be used in a while , which runs as long as b < a-1 and inserts the missing rows filled with zeros. 1 at the end of the script will finally print an input line.
source share