# Usage: gawk -f sarip 2006 2007...500F saradata.out # Where saradata.out is the output of sara # and 2006 2007...500F are the addresses of the desired monitor data # Version 1.1 971119 PAL # Read in list of desired monitor points: BEGIN { numpoints = ARGC-2 for (i=1; i<=numpoints; i++) { point[i]=ARGV[i] # (point[] needed to keep track of sequence of monitor points) ARGV[i]="" data[point[i]]=" "} # (Unknown-data points set to 7 spaces to preserve columns) # Now print header line to identify columns. printf ("TIME ") for (i=1;i<=numpoints;i++) printf("%7s",point[i]) printf("\n\n") } # Body of program: # if line starts with a new timestamp, print accumulated data. {if ($3 != oldtime) { gooddata=0 # Check first to see if there is any data to print for (i=1;i<=numpoints;i++) if (data[point[i]] != " ") gooddata = 1 if (gooddata==1) {printf("%6s",oldtime) for (i=1;i<=numpoints;i++) {printf("%7s",data[point[i]]) data[point[i]]=" "} printf ("\n") } # Save this timestamp to check next line against oldtime=$3} # Next line executes for every line in file. It reads each field after # the first four, and puts the data into the array data[] with the # subscript equal to the data address. # e.g., 204E:16375 puts the value 16375 in data[204E]. # When all lines with the same timestamp have been read, the # "if (#3 != oldtime)..." above # will print (only) the data[] values whose subscripts are in point[]. for (i=5;i<=NF;i++) data[substr($i,1,4)]=substr($i,6) } # Reached end of input file, print any remaining good data. END { for (i=1;i<=numpoints;i++) if (data[point[i]] != " ") gooddata = 1 if (gooddata == 1) {printf("%6s", oldtime) for (i=1;i<=numpoints;i++) printf("%7s",data[point[i]]) printf("\n")} }