标签:$1 time bsp server print nbsp com 显示 fse
ntpdate -u time.sh.ctriptravel.com
mm=`ntpdate -u time.sh.ctriptravel.com`
[root@SERVER ~]# echo $mm
7 Jan 15:56:19 ntpdate[658828]: adjust time server 10.15.220.47 offset 0.164042 sec
[root@SERVER ~]# echo $mm|awk ‘{print $10}‘
0.164042
取值第十列(print $10)
[root@SERVER ~]# echo $mm|awk -F sec ‘{print $1}‘
7 Jan 15:56:19 ntpdate[658828]: adjust time server 10.15.220.47 offset 0.164042
以sec为锚点显示左边的值(print $1为左边,print $2为右边)
[root@SERVER ~]# echo $mm|awk -F sec ‘{print $1}‘|awk ‘{ print $(NF) }‘
0.164042
[root@SERVER ~]# echo $mm|awk -F sec ‘{print $1}‘|awk ‘{ print $(NF-2) }‘
10.15.220.47
[root@SERVER ~]# echo $mm|awk -F sec ‘{print $1}‘|awk ‘{ print $(NF-1) }‘
offset
以sec为锚点显示倒数第一列的值print $(NF)(print $(NF-1)为倒数第二列,print $(NF-2)为倒数第三列)
nn= `echo $mm|awk -F sec ‘{print $1}‘|awk ‘{ print $(NF) }‘`
echo $mm
mm=`ntpdate -u time.sh.ctriptravel.com`
nn=`echo $mm|awk -F sec ‘{print $1}‘|awk ‘{ print $(NF) }‘`
echo $nn
echo $mm|awk -F sec ‘{print $1}‘|awk ‘{ print $(NF) }‘|awk -v num1=$nn -v num2=0.0099 ‘BEGIN{print(num1>num2)?"0":"1"}‘
标签:$1 time bsp server print nbsp com 显示 fse
原文地址:https://www.cnblogs.com/marsram/p/12162865.html