1

AWK: Help inserting records between various matches

view story
linux-howto

http://www.unix.com – Hello, my apologizes if the title is a bit confusing. I am currently working with a series of files that have the form: 2 3 7 17 21 However, I need to insert records such that I have: 0 0 1 0 2 1 3 1 4 0 5 0 6 0 7 1 .... And so on. Currently I have the following script: Code: awk '{{temp=$1;getline;temp2=$1};if((temp2-temp)>1){for(i=temp;i<temp2;i++){print i,0}}{print $1, 1}}' Which produces: 3 1 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 1 21 1 I've played around with this for awhile, but seem to have hit a brick wall ( :wall: ). Any help would be (HowTos)