Filling in gaps with awk or anything
awk, bash
Solution
this one-liner may work for you:
awk '$1>++p{for(;p<$1;p++)print p" 0 0 0 0 0"}1' file
with your example:
kent$ echo '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'|awk '$1>++p{for(;p<$1;p++)print p" 0 0 0 0 0"}1'
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
Problem
I have a list such as below, where the 1 column is position and the other columns aren't important for this question. ``` 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 ``` I want to fill in the gaps such that the list is continuous and it reads ``` 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 ``` I am familiar with awk and shell scripts, but whatever way it can be done is fine with me. Thanks for any help..