Using “seq”, If one column is equal to 5, continue the other column

For example, I want to start from the far right column, and once that reaches 5, continue the count from the second farthest column.

``````0.0.0.0
0.0.0.1
0.0.0.2
0.0.0.3
0.0.0.4
0.0.0.5
0.0.1.5
0.0.2.5
0.0.3.5
0.0.4.5
0.0.5.5
0.1.5.5
0.2.5.5
0.3.5.5
0.4.5.5
0.5.5.5
1.5.5.5
2.5.5.5
3.5.5.5
4.5.5.5
5.5.5.5
``````

So far, I was thinking of using:

``````for i in \$(seq 0 5); do echo "0.0.0.\$i"; done
``````

and once `i == 5`, then well set `i=0`, and move the echo to the third position.

• @thanasisp Yes, the ending would remain to the max value it reached. The previous user did offer a printf that does work nicely, but I'm trying to get a seq to work – curiousJoe Dec 4 '20 at 8:35
• It's a different thing to print the combinations or permutations from what you describe here. edit your question and make the question clear, with a correct output. – thanasisp Dec 4 '20 at 8:38
• @thanasisp I thought I made that quite clear by showing it ends of at 5.5.5.5 and not any values being changed – curiousJoe Dec 4 '20 at 8:40
• Shouldn't the title be changed in "...If one column is equal to 5, ..." ? – Httqm Dec 4 '20 at 10:13
• @curiousJoe please validate if the edit I did is what you want? – αғsнιη Dec 4 '20 at 10:48

Using loop:

``````{
for i in \$(seq 0 5); do echo "0.0.0.\$i"   ; done;
for j in \$(seq 1 5); do echo "0.0.\$j.\$i"  ; done;
for k in \$(seq 1 5); do echo "0.\$k.\$j.\$i" ; done;
for l in \$(seq 1 5); do echo "\$l.\$k.\$j.\$i"; done;
}
``````

Using `awk` and more flexible to increase the repeat time as well as adjustable number of fields from the single line input:

``````awk -F"." -v OFS="." -v repeat=5 '
{ print \$0;
for(c=NF; c>=1; c--){
for (i=1; i<=repeat; i++) { \$c=i ; print \$0; };
};
}' <<<'0.0.0.0'
``````
• Would it be possible to use seq four different times ? – curiousJoe Dec 4 '20 at 8:20
• Really nice awk script! – Ed Morton Dec 5 '20 at 17:29
• @EdMorton thank you, I'm happy hearing this from you who is expert in awk field : ) – αғsнιη Dec 5 '20 at 17:55