3
|
1 #!/bin/awk -f
|
|
2 BEGIN{
|
|
3 true = 1;
|
|
4 false = !true;
|
|
5 hashmarkcount = 0;
|
|
6 iscomment = true; # true for the first lines
|
|
7 i=0;
|
|
8 j=0;
|
|
9 }{
|
|
10 if("#" == $1) {
|
|
11 hashmarkcount++;
|
|
12 iscomment = true;
|
|
13 } else
|
|
14 iscomment = false;
|
|
15 if(hashmarkcount < 6 && !iscomment ){ #get the first vector (x)
|
|
16 x[i]=$1;
|
|
17 i++;
|
|
18 }
|
|
19 else if ( !iscomment ){ # so we are at y
|
|
20 y[j]=$1;
|
|
21 j++;
|
|
22 }
|
|
23
|
|
24 }END{
|
|
25 # first padding at the beginning
|
|
26 for (j=0.2;j<x[0];j+=0.2) {
|
|
27 printf("%6.3f %6.4f\n", j,3.0);
|
|
28 }
|
|
29 # note i sould be equal to y
|
|
30 # we are considering 'i' number of data (
|
|
31 # ys without x values will be discarded, xs without y will
|
|
32 # get y value 0
|
|
33 # we are treating 'i' as the length of the vectors
|
|
34 for (j=0;j<i;j++) {
|
|
35 printf("%6.3f %6.4f\n", x[j],y[j]);
|
|
36 }
|
|
37 # zero padding at the end
|
|
38 for(j=x[j-1]+0.2;j<=12.0;j+=0.2) {
|
|
39 printf("%6.3f %6.4f\n", j,0.0);
|
|
40 }
|
|
41 }
|