#!/bin/bash # Takes data file with: # Day Month Year timeofday val1 val2 ... valn # outputs: # Day Month Year timeofday val(column_number) normalized_column_value # useage: normalize column_number file_name # find number of values on the line linelen=`head -1 <$2 | dm N` # check for valid column value if [ $1 -le $linelen ] then # determine number of years of data for file firstyr=`head -1 < $2 | dm x3` lastyr=`tail -2 < $2 | dm x3 | stats max` let totyr=lastyr-firstyr+1 # set up initial lastval array for nline in $(seq $linelen) do lastval[nline]=0 done # set first day, first month and first year values as well lastval[1]=`head -1 < $2 | dm x1` lastval[2]=`head -1 < $2 | dm x2` lastval[3]=$firstyr # grab entire file into memory nline=0 for singval in ${lineval[@]} do let nline=nline+1 lastval[nline]=${nextval[nline]} nextval[nline]=$singval if [ $nline -eq $linelen ] then # same day? if [ nextval[1] -eq lastval[1] ] then # same day else # new day fi fi nline=0 done else echo "Column number $1 does not exist in the file." fi