First page Back Continue Last page Overview Graphics
Example 3-5 awk command
Calculations and formatted print
The geographical coordinates of Azerbaijan network is given in file Azerbaijan_stn.dat in example3_awk directory. We would like to reformat it to hypo77 format which is used by seisan and hypo77. In hypo77, the latitude and longitude are given in degree and minutes. With the following command we do the required computation and reformatting. Please notice that instead of print, printf or formatted print is used. printf in awk is exactly similar to that in C programming language.
awk 'NR >1 {lat=substr($2,1,2);lat2=substr($2,4,3); long=substr($3,1,2);long2=substr($3,4,3); printf "%5s %2d%5.2fN %2d%5.2fE%4d \n", $1,lat,lat2*.06,long,long2*.06, $4}' Azerbaijan_stn.dat