: !/bin/sh month="$1" mm=`echo "$month" | awk '{ print substr($1,1,2) }'` cc=`echo "$month" | awk '{ print substr($1,3,2) }'` yy=`echo "$month" | awk '{ print substr($1,5,2) }'` #echo "$0: mm=[$mm] cc=[$cc] yy=[$yy]" carrier = "Telmax21" #infile=`ls t21K3_${mm}${cc}${yy}.csv` infile=`ls c9_${mm}${cc}${yy}.in` outfile="${carrier}_${month}.out" #echo "$0: infile=[$infile] outfile=[$outfile]" rm -f $outfile sed -e 's/ $//' "$infile" | \ awk -F "," -v "billmonth=$month" -v "carrier=$carrier" ' function trim(is) { #sub(/^\"/,"", is) #sub(/\"$/,"", is) while (sub(/^ /, "", is) != 0) is = is "" while (sub(/ $/, "", is) != 0) is = is "" return is } ##################################################### # main BEGIN { monthstr[1] = "Jan"; monthstr[2] = "Feb"; monthstr[3] = "Mar"; monthstr[4] = "Apr"; monthstr[5] = "May"; monthstr[6] = "Jun"; monthstr[7] = "Jul"; monthstr[8] = "Aug"; monthstr[9] = "Sep"; monthstr[10] = "Oct"; monthstr[11] = "Nov"; monthstr[12] = "Dec"; billmm = 0 + substr(billmonth,1,2) billyyyy = 0 + substr(billmonth,3,4) billperiod = monthstr[billmm] " " billyyyy } { gsub(/\r/, "") # remove CR gsub(/\032/, "") # remove FF # from t21K3_082002.csv #t21,Telmax21,Mobile,01/08/2002,000028,origin,destdesc,0414771625,rate,20,0.18,T,1414,T,188750 # from c9.in #ADT,ADT01FOC,53368,02/09/2002,065924,37,7010,out,13131,O,Outgoing Internal Network,100,0.0, servicenumber = $2 callclass = $10 sdate_str = $4 btxt_stime_str = $5 btxt_origin = "" #$6 btxt_destination = $11 btxt_dialled = $9 btxt_rate = "" dursecs = $12 costinclgst = $13 printf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%d|%0.2f|\n", servicenumber, carrier, callclass, billperiod, sdate_str, btxt_stime_str, btxt_origin, btxt_destination, btxt_dialled, btxt_rate, dursecs, costinclgst) #printf("\n") } END { } ' >$outfile test -f callclass.uniq && mv -f callclass.uniq callclass_$1.uniq test -f btxt_dialled.uniq && mv -f btxt_dialled.uniq btxt_dialled_$1.uniq test -f btxt_duration.uniq && mv -f btxt_duration.uniq btxt_duration_$1.uniq exit 0