I am trying to output the results of my shell script using printf. To keep the results aligned in column, I am using tab as:
printf "%s\t %s\t %s\t %s\t %s\t %s\t %s\n" $i $est $var_m $jk $mst $var_M $Tes >>tmp
But the problem is, for some cases, the results are bit long, as a output of say,
var_M=`echo "scale=8;(-1/$jk + (e(2*$jk)+1)/(e(2*$jk)-1))"|bc -l `
So, it will be better for me, if I can format print to the column, something like:
printf "%s *goto column 20* %s *go to column 30* " $i $est >>tmp
is this possible?
I have checked this thread and also the man pages, but failed to find it. Is this possible?
NB: I do not have any special reason to stick to printf. so any other suitable command that can do the thing (easily) is also welcome.
EDIT: tried: printf "%-2s %-8s\n" $i $est >>tmp
which is not clearly working:
4.0 0.17169E-02
5. 0.17156E-02
10. 0.17129E-02
(The 2nd row/2nd column is not aligned, just like the case of list-formatted output)
"$i"
and"$est"
) unless you have a good reason not to, and you’re sure you know what you’re doing.