I am currently using a list ['/etc/hostname', '/opt/sme/sme.conf'] in python script, and to do find and replace oldhostname with newhostname in those files in the list, which works great.
filelist = ['/etc/hostname', '/opt/sme/sme.conf']
for filename in filelist :
f = open(filename,'r')
filedata = f.read()
f.close()
newdata = filedata.replace('oldhostname',newhostname)
f = open(filename,'w')
f.write(newdata)
f.close()
now I have to replace environment value in a file. Instead of repeating above code twice to replace environment value in a file. Can someone please suggest how to write above code using a tuple as input.
[('newhostname',oldhostname,'/etc/hostname'),('newhostname',oldhostname,'/opt/sme/sme.conf'),('appenv',newappEnv,'/opt/sme/sme.conf')]