Problem: There are 600 IPs in the ip.lt file, 3 document templates, and three document name structures are "ip+ series of Strings", Requirements: 1. Divide 600 IPs into 3 points, create 600 documents based on three templates, same name structure as template; 2 modify time and DNS Server in 600 documents
Programming:
#!/bin/bash Num=1 While [$num-le 600] Do Ipaddr= ' Sed-n "$num" P ip.lt ' If [$num-le];then Cp/home/ghost/test/192.168.107.105_66c221be-6ab2-ef53-1589-fe16877914e1_chk.xml./backup1/"$ipaddr" _ 66c221be-6ab2-ef53-1589-fe16877914e1_chk.xml Sed-i ' s/2014-5-29/2016-8-11/g './backup1/"$ipaddr" _66c221be-6ab2-ef53-1589-fe16877914e1_chk.xml Sed-i ' S/dns Servers ........... : 172.21.35.146/dns Servers ........... : 8.8.8.8/g './backup1/"$ipaddr" _66c221be-6ab2-ef53-1589-fe16877914e1_chk.xml Fi If [$num-le 400-a $num-GT]; then Cp/home/ghost/test/192.168.98.102_66c221be-6ab2-ef53-1589-fe16877914e2_chk.xml./backup2/"$ipaddr" _ 66c221be-6ab2-ef53-1589-fe16877914e2_chk.xml Sed-i ' s/2014-5-31/2016-8-11/g './backup2/"$ipaddr" _66c221be-6ab2-ef53-1589-fe16877914e2_chk.xml Sed-i ' S/dns Servers ........... : 172.21.48.22/dns Servers ........... : 8.8.8.8/g './backup2/"$ipaddr" _66c221be-6ab2-ef53-1589-fe16877914e2_chk.xml Fi If [$num-gt];then Cp/home/ghost/test/192.168.99.67_66c221be-6ab2-ef53-1589-fe16877914e3_chk.xml./backup3/"$ipaddr" _ 66c221be-6ab2-ef53-1589-fe16877914e3_chk.xml Sed-i ' s/2014-5-31/2016-8-11/g './backup3/"$ipaddr" _66c221be-6ab2-ef53-1589-fe16877914e3_chk.xml Sed-i ' S/dns Servers ........... : 172.21.35.146/dns Servers ........... : 8.8.8.8/g './backup3/"$ipaddr" _66c221be-6ab2-ef53-1589-fe16877914e3_chk.xml Fi num=$ (($num + 1)) Done |
Experimental results: View BACKUP1,BACKUP2,BACKUP3 directory, 1
Figure 1
Randomly pick a file generated to view time and DNS server,2 and Figure 3
Figure 2
Figure 3
My shell script