注意sed中使用变量,需要加单引号
localip=`ip addr|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|sed 's/\/.*$//'`
sed -i 's/var ip = "192.168.133.29"/var ip = "'$localip'"/g' `grep -rl 192.168 /root/mygithub/myDjango/`
注意sed中使用变量,需要加单引号
localip=`ip addr|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|sed 's/\/.*$//'`
sed -i 's/var ip = "192.168.133.29"/var ip = "'$localip'"/g' `grep -rl 192.168 /root/mygithub/myDjango/`
本文标题:linux shell设置IP
本文链接:https://www.haomeiwen.com/subject/uruucqtx.html
网友评论