I want to replace a string based on each line of list.txt and create a new file with the name of the string collected.
*Content of list.txt*
1. python sample.py
2. file created: new_server
3. cat new_server
*Content of list.txt*
Output:new_server
new_server2
new_server3*Content of zabbix_agentd.conf*Output:Hostname=serverfin = open("zabbix_agentd.conf", "rt")
fout = open(new_server_string_collected, "wt")
for line in fin:#
fout.write(line.replace('Hostname=server', 'Hostname=new_server'))
fin.close()
fout.close()
fh = open('list.txt')
while True:
line = fh.readline()
print(line)
if not line:
break
fh.close()*Results expected*1. python sample.py
2. file created: new_server
3. cat new_server
Output:Hostname=new_server
