I have file something like this
hostname ser1-xyz
myuser name
passwd secret
group 1234
hostname ser2-xyz
myuser name
passwd secret
group 2345
I need to find the line first appearance of host named "ser1-xyz" and modify it as "ser1" and increment it's the group value by 1
So that final file looks like :
hostname ser1
myuser name
passwd secret
group 1235
hostname ser2-xyz
myuser name
passwd secret
group 2345
Currently I'm following code,which can modify the "ser1-xyz" into "ser1"
for line in fileinput.FileInput(fn,inplace=1):
line = line.replace(search,replace)
But how to increment group value?