My shell script

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.