awk sort help

  1. The problem statement, all variables and given/known data:

I dont know what I do wrong, I am trying to create shell programming database:

I have this command first:
[ ! -f $fname ] && > $fname
...
echo $Name:$Surname:$Agency:$Tel:$Ref: >> $fname

then I have
echo " Name Surname Agency Tel email Ref"
echo ================================================
...

  1. Relevant commands, code, scripts, algorithms:
    sort -t : +1 $fname | awk -F '{printf ( "%-8.8s%-9.9s%-9.9s%-11.11s%-8.8s%-9.9s%" $1,$2)}'

  2. The attempts at a solution (include all code and scripts):
    I have tried with and without the FS "-F" the error was." sort warning : "+number" syntax is deprecated please use "-k number" only with -F the error is above the table and without -F it is below the table.

  3. School (University) and Course Number:

---------- Post updated at 08:22 AM ---------- Previous update was at 07:27 AM ----------

Hi All,

Thanks, I have found the solution:

I have just replaced the +1 with -k 1 and it worked perfectly no error but it will not show the contents of the database..
Anyone can help ?

Cheers

First check whether you get sorted output using sort command without awk, then try awk.

awk -F '{printf ( "%-8.8s%-9.9s%-9.9s%-11.11s%-8.8s%-9.9s%" $1,$2)}'

May be you needed...
awk -F":" '{printf ( "%-8.8s%-9.9s%-9.9s%-11.11s%-8.8s%-9.9s%", $1,$2,$3,$4,$5,$6)}'

have a look at awk document.

Tnx Rakeshawasthi,

Tried ...awk -F":" ... got error saying: awk: runtime error: not enough arguments passed to printf(....

When however I added "\n" problem solved..

Thank you very very much for your help