First page Back Continue Last page Overview Graphics
Example 3-3: awk command
The substr facility
It is a common practice to encounter cases where information in different columns are not separated by a space or some other character. For example in file example3_awk/earthquake_catalog.dat for events happening in two digit month and two digit days, the column for month stick to the day column. Thus we can not extract column lat and long using the approach in the previous slides. In these cases, we use substr facility within awk command to extract our desired information. We request our data by specifying the starting space column (here 26) and width of space columns (17 here) instead. Notice $0 stands for full line
awk ' {print substr($0,26,17)}' earthquake_catalog.dat