Sed command to find, manipulate and replace a number

Hi, Im very new to the world of sed so I'm really not even sure if this is possible. What i need to do is read from a flat file and every time i see this line:

VAL=123,456

I need to change 456 to 457 for every occurence of this line in the file. The numbers 123 and 456 are different for every instance of VAL. So basically i need to get VAL= skip the next value and grab the value after the "," and then add one to and subsitiute it back in.

Is it possible?

Try awk

awk 'BEGIN{FS=OFS=","}/^VAL/{$NF=$NF+1}1' file

HI,
Check out this!!!!!!!!!!!!!!

sed 's/VAL=123,456/VAL=123,457/g' fielname

Cheers

@aajan please read the OP request carefully.

Thanks Danmero - I tried the awk command but it gave me a syntax error.. not much other info on the error

for that syntax - use nawk or /usr/xpg4/bin/awk

Brilliant!! Thank you both so much!! I'm very slowly getting my head around this stuff, this is a great help :smiley: