获取指定域名的IP地址:
#!/bin/bash if [ $# -lt 1 ]; then echo $0 need a parameter exit 0 fi ADDR=$1 TMPSTR=`ping ${ADDR} -c 1 | sed ‘1{s/.*(\([^ ]*\)) 56.*/\1/;q}‘` #TMPSTR=`ping ${ADDR} -c 1 | sed ‘1{s/[^(]*(//;s/).*//;q}‘` echo ${TMPSTR}
原文地址:http://ldhqy.blog.51cto.com/2788106/1431073