我的配置文件中有一行如下:
server 192.168.3.66 iburst minpoll 3 maxpoll 6
我希望修改里面的ip地址改为192.168.3.123如何实现你,配置文件名为/etc/ntp.conf
#!/bin/sh
ip="192.168.3.123"
str1=`cat /etc/ntp.conf | grep server`
str2="server "$ip" iburst minpoll 3 maxpoll 6"
command=s@$str1@$str2@
sed -i "$command" /etc/ntp.conf