removing a particular field from some of the lines in a filed

Hi All,

i have a file having multiple lines but mainly constitues of following two types

1) Sat,Oct,1,01:04:51,2011,Local,ESSBASE0,Info(1051037),Logging,out,user,210073155,,,active,for,63,minutes,GETS_SAL,loaded
2) Thu,Sep,20,13:08:52,2012,Local,ESSBASE0,50,Info(1051037),Logging,out,user,hypadmin,,,active,for,0,minutes,Application,GETS_GL

need to bring all the lines in the same format by removing the field '50'(highlighted in red) from the lines containing it. this filed mainly contains 2 digit numbers and can be values other than 50.

Thanks in advance :slight_smile:

one simple way..:smiley:

sed 's/ESSBASE0\,[0-9][0-9]/ESSBASE0/g' file
$ nawk -F, -v OFS=, 'NF==21{for(i=8;i<NF;i++)$i=$(i+1);NF=20}1' input.txt
Sat,Oct,1,01:04:51,2011,Local,ESSBASE0,Info(1051037),Logging,out,user,210073155,,,active,for,63,minutes,GETS_SAL,loaded
Thu,Sep,20,13:08:52,2012,Local,ESSBASE0,Info(1051037),Logging,out,user,hypadmin,,,active,for,0,minutes,Application,GETS_GL

if you dont have nawk, then try with awk