#! /bin/bash # shell script to extract the et column from a hydro.out # format file, divide it out into single year segments, # wrap it into a 8 line UNSAT-H format, placing it into # separate files for each year with the year + 1900 in # the file name for all the years in the hydro.out format # file. # find maximum year value in file and set to variable maxyears=`dm "if N>1 then INPUT else SKIP" <$1 | dm x3 | stats max` # set first year let year=0 while [ "$year" != "$maxyears" ] do let year=year+1 # shift into 1900 year range let outyear=year+1900 # first line, skips lines without full columns # second line, selects desired year # third line, pulls eight values unto one line # '$!N' stops getting lines at the last line # fourth line, adds comma to end of each line dm "if N>1 then INPUT else SKIP" <$1 | \ dm "if x3=$year then x4/10 else SKIP" | \ sed -e '$!N' -e '$!N' -e '$!N' -e '$!N' -e '$!N' -e '$!N' -e '$!N' -e 's/\n/,/g' | \ sed 's/$/,/' > "pet$outyear.pen" echo "created pet$outyear.pen evapotranspiration file" done