Script to generate sequence of numbers

I need awk script to generate part number sequencing based on data in multiple columns like below

Input File
---------
Col A|Col B|Col C|
1|a|x|
2|b|y|
 |c|z|
 | |m| 
 | |n|

And out put should be like

1ax
1ay
1az
1am
1an
1bx
1by
1bz
1bm
1bn
1cx
1cy
1cz
1cm
1cn
2ax
2ay
2az
2am
2an
2bx
2by
2bz
2bm
2bn
2cx
2cy
2cz
2cm
2cn

Thanks

Ok. Please post the script you have tried.

awk -F '|' 'NR == 1{next} $1 !~ /^[ \t]*$/{a[++m]=$1} $2 !~ /^[ \t]*$/{b[++n]=$2} $3 !~ /^[ \t]*$/{c[++p]=$3}
END {for(i=1; i<=m; i++) {for(j=1; j<=n; j++) {for(k=1; k<=p; k++) print a b[j] c[k]}}}' file

Posted by SriniShoo:

Hello SriniShoo,

Please don't take it wrong, but we should respect other forum member's response as Jim has replied and asked user to come up with what user has tried, so we should wait for user's reponse as our forum's aim is to help people in learning. So it's a request please try to avoid this and try to follow the forum rules as this is the BEST forum I have seen yet. This forum is really a big, nice platform to learn.

Thanks,
R. Singh


  1. \t ↩︎

  2. \t ↩︎

  3. \t ↩︎

Please do not post till the thread owner has replied, thanks

I haven't tried any script..but the echo command did generate the similar output, but I need a script to run it on different set of column & row combinations.

So far You have only posted thread asking for awk script without ever thanking those who helped nor even tried to understand the code you were given, and you just come when new post arrive and leave just after..., we are not here to do the work for you, so show us now an awk script since it is what you want, that tries to do what you desire and the output showing what isnt working and maybe then you will be given assistance. Any full solution posted here from now on will just be deleted...