Setting Varible with AWK in KSH

I am trying to set a variable from this AWK command in KSH but I keep getting an error that says my variable cannot be found.

LOADNO = $(awk -F"|" 'NR==1{print $2}' file.txt)

If I just run awk -F"|" 'NR==1{print $2}' file.txt I get the right value but as soon as I try to assign this variable it does not work.

Any help would be appreciated!!!

Perhaps it's the spaces around the =? There should be no spaces either side of that.

1 Like