#!/bin/sh # do_h2o2: find day containing most measurements for H2O2 # usage: do_h2o2 file # output: Year H2O2 ppbv # 178.010417 0.17 # 178.024306 0.18 # first do some command-line checking if [ $# -ne 1 ]; then printf "usage: do_h2o2 file\n"; exit; fi if [ ! -f "$1" ]; then printf "file: $1 does not exist\n"; exit; fi # prompt for output filename printf "\nPlease enter output filename:\n" read outname # find day with most measurements # save to variable: frequent frequent=` cat $* | cut -c1-3 | sort | uniq -c | sort +0rn | head -1 | field -2` printf "\nprocessing file: $1, day number: $frequent\n" printf "Year H2O2 ppbv\n" > $outname # get most-frequently occurring day from input file grep "^$frequent" "$1" | tr ' ' ' ' | sort +0rn >> $outname printf "\noutput stored as file: $outname\n"