I tried running the below
awk 'BEGIN { printf ("%s %-51s %s %-7s %s",$var1,$var2,$var3,$var4,$var5)}'
from the command prompt and it is not working.
Getting the error
awk: Field $() is not correct.
The source line number is 1.
Actually my requirement is to form a string based on a particular format.
The format i have mentiioned above.
But in UNIX script i am not able to do the formatting.
Try var1, var2, var3, ... instead. $var1 means "the field whose position is stored in var1[/b], but since you have not even read any records yet it is meaningless.
Unlike perl and shells, awk does not require its variables to be prefixed by $.