sed.bash

作者: HaoDongZ | 来源:发表于2021-01-15 10:17 被阅读0次
#!/bin/bash

filepath="/abc/application/bas/agent/config/agent.config"
appnames="zhd"
echo $appnames
ipaddress=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
echo $ipaddress
hostnames=`hostname`
echo $hostnames

sed -i  "s/appname/${appnames}/g"   $filepath
sed -i "s/ipaddr/${ipaddress}/g"    $filepath
sed -i "s/hostname/${hostnames}/g"  $filepath
cat agent.config.bak |grep -v  "^#"|grep -v "^$"
agent.service_name=${SW_AGENT_NAME:appname}
agent.instance_name=${SW_AGEENT_INSTANCE_NAME:hostname:ipaddr}

相关文章

网友评论

      本文标题:sed.bash

      本文链接:https://www.haomeiwen.com/subject/hmmiaktx.html