Please help. How to print number with 'awk'?

Dear all,

I have to transform a bunch of files into a new format. how to do it with bash script, especially with 'awk' command.

the original data

 O,0,0.2839896442,-1.1628392411,-1.5976515479
 Cr,0,-0.0502858628,-0.1725974837,-0.380627632
 C,0,2.4506658279,-0.476964918,0.2299298249
 C,0,1.6651497007,-1.0345206931,1.1799564362
 H,0,2.7611063963,-1.0380822456,-0.6461973059
 H,0,1.3643870456,-2.0779397457,1.1097563185
 H,0,1.4340863236,-0.5111553249,2.1054910071
 H,0,2.8502644351,0.5285428858,0.3417072936

the new format like this:

O     0.2839896442   -1.1628392411    -1.5976515479
Cr   -0.0502858628   -0.1725974837    -0.380627632
C     2.4506658279   -0.476964918       0.2299298249
C     1.6651497007   -1.0345206931      1.1799564362
H     2.7611063963   -1.0380822456     -0.6461973059
H     1.3643870456   -2.0779397457      1.1097563185
H     1.4340863236   -0.5111553249      2.1054910071
H     2.8502644351    0.5285428858       0.3417072936

Each column should be aligned exclusively.

Please help me. otherwise, I have to do this work by hand. :confused:

thank you in advance!

zhen

$ awk -F, '{printf "%-3s %15s %15s %15s\n", $1, $3, $4, $5}' file
 O     0.2839896442   -1.1628392411   -1.5976515479
 Cr   -0.0502858628   -0.1725974837    -0.380627632
 C     2.4506658279    -0.476964918    0.2299298249
 C     1.6651497007   -1.0345206931    1.1799564362
 H     2.7611063963   -1.0380822456   -0.6461973059
 H     1.3643870456   -2.0779397457    1.1097563185
 H     1.4340863236   -0.5111553249    2.1054910071
 H     2.8502644351    0.5285428858    0.3417072936
awk -F, '{ print $1 "\t" $3 "\t" $4 "\t" $5 }' inputfilename

excellent, it works very well! thanks a lot!