以下脚本将提示addr
附近语法错误。
for ip in `cat /etc/hosts | awk '{print $1}'`
addr=`ifconfig | grep 192 |awk '{print $2}'`
do
echo $ip
echo $addr
done
addr
变量不能放在for和do之间。这样才正确
addr=`ifconfig | grep 192 |awk '{print $2}'`
for ip in `cat /etc/hosts | awk '{print $1}'`
do
echo $ip
echo $addr
done
for ip in `cat /etc/hosts | awk '{print $1}'`
do
addr=`ifconfig | grep 192 |awk '{print $2}'`
echo $ip
echo $addr
done