Replacing column values

hi all ,

( perl)
i am trying to replace jst one column in a file for eg

month dayofweek dealar car-name
jan thurs mercedes c300
feb wed lexus is300

all this data is in a master file and i want to replace jan with 1
feb -2 .. march with 3 and so onn .. upto dec is 12

any advice ..

thanks

awk 'NR != 1{$1=NR-1}1' infile

thanks huaihaizi3

could u explain this a lil .. i am new to awk and sed commands .. also will this go across the entire file? replacing jan to 1 and feb to 2 or ny month to a corresponding number

$1 : the first field
NR : Record Separator(the default value of NR is '\n',it's line number here)
Just as you file shows that the value month starts from the second line(NR=2)

Not exactly. NR is the Number of Records seen so far.

A possible solution:

awk 'BEGIN{split("jan_feb_mar_apr_may_jun_jul_aug_sep_oct_nov_dec",a,/_/);for (i in a) m[a]=i}{print m[$1],$2,$3'}' infile

Or the terse version of it:

awk 'BEGIN{split("jan_feb_mar_apr_may_jun_jul_aug_sep_oct_nov_dec",a,/_/);for (i in a) m[a]=i}{$1=m[$1]}1' infile

yeah,just a mistake,sorry
RS is Record Separator,NR is the Number of Records(line number here)