hello everyone!!! a have some really big question marks and i hope u can give me some answers!
lets say i have an input file like this :
a b d g
a b c d e f g h
a c d f g h
a b c d g
i need to arrange the fields in an output file like this:
a b - d - - g -
a b c d e f g h
a - c d - f g h
a b c d - - g -
for this i came up with the script below :
awk ; { if(max_nf<NF)
max_nf=NF;
max_nr=NR
for(i=1;i<=NF;i++)
v[i,NR]=$i;
}
END {for (i=1;i<=max_nr;i++)
for(j=1;j<=max_nf;j++)
{if (j==1 && v[j,i]!="a")
{for(k=max_nf;k>j;k--)
v[k,i]=v[k-1,i];
v[j,i]="-";}
------------------------
if (j==8 && v[j,i]!="a")
{for(k=max_nf;k>j;k--)
v[k,i]=v[k-1,i];
v[j,i]="-";}
}
for(i=1;i<=max_nr;i++)
{for(j=1;j<=max_nf;j++)
printf("%s ",v[j,i]);
printf("\n");}
}
Now, if i run the script on a Ubuntu system it works perfectly!
But i really HAVE to run it on a Solaris 5.9 and there is the problem!!!
Apparently i has "syntax errors" at assigning v[i,Nr]=$i, and at all "for" loops .
So, it's not a code problem, but a syntax one.
The thing is both systems have /usr/bin/awk and /usr/bin/nawk.
How can i find out what my version of awk can support and what it can't?
And more importantly, how do i rewrite the script in order to work on the Solaris?
Hope anyone cand help me
