echo testing | awk '{x} {print substr($x,1,3)}'
But it comes out with the following error:
awk: 0602-550 A statement occurred that is not valid.
The input line number is 1.
The source line number is 1.
Can someone pls tell me what is it that i have gotten wrong. The same
thing is working on another server. Is there any configruation or
profile setting which I am missing
With gawk 3.1.3 on Linux, I get this response:
echo testing | awk '{x} {print substr($x,1,3)}'
tes
You are using some ancient broken AWK implementation.
> But it comes out with the following error:
>
> awk: 0602-550 A statement occurred that is not valid.
>
> The input line number is 1.
>
> The source line number is 1.
It may be the substr() function which may be missing in the AWK on your AIX.
It may also be the semicolon (;) between the curly braces that you failed to insert.
> How do I find the version of awk in AIX?
> In linux i can do awk --version and it works
The fact that you can't do that is all you need to know. You're using
old, broken awk. Use GNU awk (gawk) or New awk (nawk) or
/usr/xgp4/bin/awk if you were on Solaris.
And please don't top-post.
Ed.
>> How do I find the version of awk in AIX?
AWK on our AIX 4.3 and 5.2 has no way to find out version.
But the man page suggests that the AWK on AIX is a nawk-variant.
>> In linux i can do awk --version and it works
Yes, that's a gawk in disguise.