我要求将我的仪表组合文件中的[我的舱面]部分移至我的板块组合文件上的另一节,标题是<编号>#SAFE#;在移到该节之后,各科之间应当有空间。
使用的代码:
#!/bin/bash
for server in `cat /home/servers.txt `
username=$1
password=$2
do
sshpass-p $PWD ssh -o stricthostchecking=no $USERNAME@$server "ed -s /home/my.cnf << EOF
/^[已婚]$/;/^[.*/ -1m$
?[已婚]?i
.
w
EOF"
done
a. 实际:
[已婚]
disable-log-bin = 1
skip-name-resolve = 1
performance-schema = 0
local-infile = 0
mysqlx = 0
open_files_limit = 200000
max_allowed_packet = 256M
sql_mode="NO_ENGINE_SUBSTITUTION"
#the below are password related of [已婚]
validate password=1
innodb_dedicated_server = 1
innodb_buffer_pool_instances = 48
[myisamck]
a=3
b=4
[sst]
d=3
c=4
# SAFE #
d=0
f=0
要求:[已婚]
section and its section should be pasted above # RSE # (
section in very small cases section is given as #SAFE##
or #SAFE#
or # RSE #
in small of my.cnf file),Please support.
预期产出:
[myisamck]
a=3
b=4
[sst]
d=3
c=4
[已婚]
disable-log-bin = 1
skip-name-resolve = 1
performance-schema = 0
local-infile = 0
mysqlx = 0
open_files_limit = 200000
max_allowed_packet = 256M
sql_mode="NO_ENGINE_SUBSTITUTION"
#the below are password related of [已婚]
validate password=1
innodb_dedicated_server = 1
innodb_buffer_pool_instances = 48
# SAFE #
d=0
f=0