Greg Wooledge wrote:
But nobody does that. It's simply unnecessary. Likewise, you don't need quotes around "on" or "off" because they don't contain special characters. You also don't need quotes around the "==" string argument that was passed in this command. It's funny that you would think you should put quotes around "on" but not around "==", isn't it.
I didn't know much about shell rules. Can you help check if my this script has any issue? I use it to check the port is opened by which process.(in our system there are many many ports opened by java (the hadoop ecosystem)).
#!/bin/bash PORT=$1 if [ -z $PORT ];then echo "$0 port" exit fi PS=`lsof -i :$PORT |grep LISTEN |awk '{print $2}'` if [ -z $PS ];then echo "no this port, or I don't have privilege to list the port" exit fi ps -efw |grep $PS |grep -v grep Thanks