美文网首页
变量用双引号包起来

变量用双引号包起来

作者: shuff1e | 来源:发表于2018-03-20 15:43 被阅读6次
    hostname=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | grep -v '192.168' | awk '{print $2}' | cut -d: -f 2)
    
    conns=$(netstat -antup | awk '$4 ~ /'"$hostname"':8080/ {print $0}' | awk '$5 !~ /'"$hostname"':.*/ {print $5}' |\
        cut -d ':' -f 1 | sort | uniq | awk 'ORS=" "')
    
    if [ -n "$conns" ];then
    echo '$hostname connected with clients: '
    echo "$conns"
    fi
    

    相关文章

      网友评论

          本文标题:变量用双引号包起来

          本文链接:https://www.haomeiwen.com/subject/yudbqftx.html