diff --git a/check_if_port_is_up/script_to_check_if_port_is_up_v1.sh b/check_if_port_is_up/script_to_check_if_port_is_up_v1.sh new file mode 100644 index 0000000..b67ca78 --- /dev/null +++ b/check_if_port_is_up/script_to_check_if_port_is_up_v1.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +function check_port { + # Check if the port number was provided + if [ -z "$1" ]; then + echo "Please provide the port number." + exit 1 + fi + + # Check if port is up or not + if ! ss -nptl | grep $1 > /dev/null; then + echo "Port '$1' is not up." + else + echo "Port '$1' is up." + fi +} + +check_port "$1"