I have a file (sysid.txt) that consist of multiple line of data (systemid and hostname) as follow
0192.4500.0000 uue01.re1
0192.4500.0010 ccu01.re1
0192.4500.0110 uue02.re1
0192.4500.0001 core1.re2
Based from info and help here, the 1st string(numbers) successfully replace as require but the 2nd string(hostname) missing and the output presented in single line when I run the code below.
file1 = open('sysid.txt', 'r')
file2 = open('sysip.txt', 'w')
file1_cont = file1.readlines()
for line in file1_cont:
line = line.replace('.', '')
f = itemgetter(slice(0,3), slice(3,6), slice(6,9), slice(9,12))
line = '.'.join(f(line.replace('.','')))
line = '{}.{}.{}.{}'.format(*map(int, f(line.replace('.', ''))))
file2.write(line)
print(line)
the output of sysip.txt
10.89.0.010.89.0.110.89.0.3210.89.0.3310.89.0.3410.89.0.3510.89.0.64
Read each line, I would like to replace 1st string(numbers) and maintain 2nd string (hostname) as below
192.45.0.0 uue01.re1
192.45.0.10 ccu01.re1
192.45.0.110 uue02.re1
192.45.0.1 core1.re2
How can i manipulate 1st string/numbers and save the output line (file2.write(line)) in new line and at the same time remain the 2nd string as above.
Thank you for your support and guidance.
#updated list.txt...
System ID Hostname
0192.4500.0000 uue01.re1
0192.4500.0010 ccu01.re1
0192.4500.0110 uue02.re1
0192.4500.0001 core1.re2
{master}