I got a problem when I tried to use loop in awk The input file is
I|A;B;C|a;b;c|1;2;3
II|D;E;F|d;e;f|4;5;6
III|G;H;I|g;h;i|7;8;9
The working awk script is
awk 'BEGIN{FS="|"}
{
printf("%s ", $1);
split($2, arr, ";");
printf("%s ", arr[2]);
split($3, arr, ";");
printf("%s ", arr[2]);
split($4, arr, ";");
printf("%s ", arr[2]);
printf("\n");
}' inputfile
But the following script does not work:
awk 'BEGIN{FS="|"}
{
printf("%s ", $1);
for (i = 1; i
