#!/bin/bash
old=MyHostKey
new=1234
sed 's/${old}/{new}/g' aaaa.conf
echo "----------------------------"
sed 's/MyHostKey/1234/g' aaaa.conf
执行上面的这个脚本,结果如下:第一个没有执行成功,为什么啊?大神们给看看吧!
bash-4.2# ./test.sh
{
"frequency":"60",
"service_name":"OS",
"Qualifier":"",
"HostKey":"MyHostKey",
"SendProxy":"http://127.0.0.1:26789",
"mem":"1",
"cpuBurden":"1",
"cpuUsage":"1",
"proces":"1",
"netItf":"1",
"tcp":"1"
}----------------------------
{
"frequency":"60",
"service_name":"OS",
"Qualifier":"",
"HostKey":"1234",
"SendProxy":"http://127.0.0.1:26789",
"mem":"1",
"cpuBurden":"1",
"cpuUsage":"1",
"proces":"1",
"netItf":"1",
"tcp":"1"
}bash-4.2#
收起