Yet another Galaxy utility (uses awk) From: dagibbs@quantum.on.ca (David Gibbs) Date: Sun, 22 Nov 1992 05:52:07 +0000 Another program that I expect has already been done, but this one is some what flexible. It is used as follows: awk -f <distance_awk> <planet1> <planet2> <input_file> Where <distance_awk> is the name of the script file <planet1> if one of the planets, can contained embedded spaces if the name is enclosed in double quote; ie: '"This planet"' is fine, as is 'This_planet', but: 'This planet' would cause problems. <planet2> name of the other planet <input_file> file containing the planet data, generally any turn report that contains the two planets in question, it will ignore extraneous junk Hope this helps someone. -David (dagibbs@quantum.qnx.com) --------------Cut here----------------------- BEGIN { if ( ARGC != 4 ) exit planet1 = ARGV[1] gsub( " ", "_", planet1 ) planet2 = ARGV[2] gsub( " ", "_", planet2 ) ARGV[1] = "" ARGV[2] = "" } $0 ~ planet1 { if ($1 == planet1) { x1 = $2 y1 = $3 } } $0 ~ planet2 { if ($1 == planet2) { x2 = $2 y2 = $3 } } END { dist = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) printf("Dist from %s to %s is %7.3f \n", planet1, planet2, dist ) } Referenced By Up