当前位置: 技术问答>linux和unix
关于脚本的小问题
来源: 互联网 发布时间:2015-11-11
本文导语: 1.sh的内容 www="netstat -an | grep LISTEN | grep :80" if [ "$www" != "" ] ; then echo "www is running" 原意是netstat -an | grep LISTEN | grep :80 命令的输出不为空表示启用了WEB服务,但实际脚本中$www的内容就是“netstat -an...
1.sh的内容
www="netstat -an | grep LISTEN | grep :80"
if [ "$www" != "" ] ; then
echo "www is running"
原意是netstat -an | grep LISTEN | grep :80 命令的输出不为空表示启用了WEB服务,但实际脚本中$www的内容就是“netstat -an | grep LISTEN | grep :80”,当然等于空了,该如何改?
www="netstat -an | grep LISTEN | grep :80"
if [ "$www" != "" ] ; then
echo "www is running"
原意是netstat -an | grep LISTEN | grep :80 命令的输出不为空表示启用了WEB服务,但实际脚本中$www的内容就是“netstat -an | grep LISTEN | grep :80”,当然等于空了,该如何改?
|
用反引号
www=`netstat -an | grep LISTEN | grep :80`
www=`netstat -an | grep LISTEN | grep :80`