While concatenating 2 values, one which expanded to fixed width & other not, I am not getting value expanded as fixed width.
Following is script for the same :
#!/bin/sh
var1="abc"
var2="def"
var1Fxd=`echo $var1 | awk '{printf("%-6s",$0)}'`
echo $var1Fxd""$var2
But, if I try -
echo "abc" | awk '{printf("%-6s",$0)}'
Then it is showing me correct result with 'abc' followed by 3 spaces.
Can anyone tell me, how I can I have var1Fxd & var2 on same echo command, since this o/p I am passing to a file.