shell 脚本中获取mysql多个字段的值
#!/bin/bashtmp=`mysql -Ne "SELECT ip,port FROM op.host WHERE os='linux' and type='支持'"|while read a b;do echo "$a:$b";done`
for i in $tmp
do
ip=`echo $i |cut -d: -f 1`
port=`echo $i |cut -d: -f 2`
echo "ip:$ip,port:$port"
done
页:
[1]