26 lines
1020 B
Python
26 lines
1020 B
Python
# Определение путей к файлам
|
|
file_path_1 = '/home/rpetrovich/code/Repos/lmru--devops-core--salt/states/jenkins-slave/files/blocked_ips.txt'
|
|
file_path_2 = '/home/rpetrovich/code/Misc/blocked_ips.txt'
|
|
output_file_path = 'merged_ips.txt'
|
|
|
|
# Чтение IP-адресов из первого файла
|
|
with open(file_path_1, 'r') as file:
|
|
ip_list_1 = file.read().splitlines()
|
|
|
|
# Чтение IP-адресов из второго файла
|
|
with open(file_path_2, 'r') as file:
|
|
ip_list_2 = file.read().splitlines()
|
|
|
|
# Объединение и удаление дубликатов с использованием множества
|
|
unique_ips = set(ip_list_1 + ip_list_2)
|
|
|
|
# Сортировка IP-адресов
|
|
sorted_unique_ips = sorted(unique_ips)
|
|
|
|
# Сохранение уникальных IP-адресов в файл
|
|
with open(output_file_path, 'w') as file:
|
|
for ip in sorted_unique_ips:
|
|
file.write(f"{ip}\n")
|
|
|
|
print("Merged IP addresses list successfully created.")
|