Increment Numbers in File

Hello,

I have a text file withe some records

20121031|5
20121030|3
20121029|1
20121028|4
20121027|6

I want to search for a patten with '20121030' and then increment the second part of the delimiter i.e. 3 by 1 to make it 4 to look like

20121031|5
20121030|4
20121029|1
20121028|4
20121027|6

thanks for the help.

awk -F"|" ' { OFS="|" } /20121030/ { print $1,$2+1; } ' file

Thanks bipinajith. Works perfectly. :b:

@bipinajith - It will print only lines having 20121030 in it...

Try

awk '{FS=OFS="|" }/20121030/{$2+=1}1' file

Oh right, I misread requester's requirement.:wall: Thanks for correcting.:b:

Thanks bipinajith and pamu :b:

perl -F'/[|]/' -alpe 'if($F[0] eq "20121030"){$F[1]+=1;print join "|",@F;next}' file
$ awk -F\| -v OFS=\| '/20121030/{$2+=1}1' a.txt
20121031|5
20121030|4
20121029|1
20121028|4
20121027|6