check_port() { echo "Checking instance port ..." netstat -tlpn | grep "\b$1\b" } if check_port 8080 then echo "port exists" exit 1 fi