1. Get specific information from a string of strings
Requirement 1: Get the IP profile of the native IP:menu.lst as the system mirror, and need to obtain the native IP information from the file (get information from the files)
1Timeout12 default 03 4 Title Live5Find--Set-root/casper/Vmlinuz6Kernel/casper/vmlinuz boot=casper ignore_uuid showmounts Ip=eth0,10.0.66.66,255.255.240.0,10.0.64.37Initrd/casper/initrd.lz
Menu.lst
Requirement 2: Modify (replace) a specific content in the original file: Centerserver.conf is the configuration file for the SCC executable, and the domain value in the configuration file needs to be changed to native IP.
1 #CenterServer config file2 3# Logging Type:syslog|cerr|cout|file4Loggingtype =cout5 6# Logging level:none| Crit| err| warning|info| Debug|STACK7LogLevel =DEBUG8#LogLevel =INFO9 Ten #sip Listen Port OneUdpport =5060 A #SCC Domain IP -Domain =10.0.73.14 -Calltimeout = - the -#RDS Client working thread num (1--8) -Rdsclientthreadnum =2 -#RDS Client Log on|if +Rdsclientlog =off - +#Daemon Process Yes|no,default=Yes AIsdaemon =No at - #Web Server Addr -Webserverurl = http://localhost:9000 - - #SCC State Database -DataBase =SCC inMysqlusername =Root -mysqluserpasswd [email protected]666 to +MsIp =127.0.0.1 -Msport =9999
centerserver.conf
Implementation script:
1#!/bin/SH2menulst="/jonet_boot/menu.lst"3Scc_path="/jonet/bin/scc/centerserver.config"4localip="' awk-f ', ' {print $ {} ' $MENULST |grep. '";5 Echo $LOCALIP6 7 MODIFY_SCC ()8 {9domain="' cat $SCC _path|grep Domain '"Ten Echo $DOMAIN One Echo $LOCALIP A#sed-E'S/domain = 10.0.66.66/domain = 10.0.73.15/g'$SCC _path -Sed-i's/' "${domain}"'/domain =' "${localip}"'/g'$SCC _path - } the - - modify_conf () - { + MODIFY_SCC - } + A modify_conf at -Exit0
conf.sh
Description: Sed-i ' s/' "${domain}" '/domain = ' ${localip} ' '/g ' $SCC _path
Because macros define DOMAIN and Localip are not available in commands using $domain and $localip, you need to use ' ${domain} ' and ' ${localip} ' to enable script substitution
1#!/bin/SH2menulst="/jonet_boot/menu.lst"3Scc_path="/jonet/bin/scc/centerserver.config"4localip="' awk-f ', ' {print $ {} ' $MENULST |grep. '";5 Echo $LOCALIP6 7 MODIFY_SCC ()8 {9domain="' cat $SCC _path|grep Domain '"Ten Echo $DOMAIN One Echo $LOCALIP ASed-i's/' "${domain}"'/domain =' "${localip}"'/g'$SCC _path - } - the modify_conf () - { - MODIFY_SCC - } + - modify_conf + AExit0
conf.sh