i have a script and i think we can achieve the objective but i am missing somewhere ?
with open("abc1.txt", "w+") as fw1, open("abc2.txt", "w+") as fw2: for i in p: if len(i.partition("/")[0]) == 4: fw1.write('int ' + i + '\n mode\n') else: i = 0 while i < len(p): start = p[i].split('/') print start if (start[0] == 'Eth1'): i += 3 else: key = start[0] #print key i += 1 while i < len(p) and p[i].split('/')[0] == key: i += 1 end = p[i-1].split('/') fw2.write('confi ' + start[0] + '/' + start[1] + '-' + end[1] + '\n mode\n')