Created
July 8, 2022 06:57
-
-
Save renkin/a664a96d489aaeb1bf75c9938d02b503 to your computer and use it in GitHub Desktop.
Greps for a port in netstat output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_printUsage() { | |
echo 'Usage: checkPortUsage.sh <port>' | |
} | |
### Main ### | |
if [[ $# -ne 1 ]]; then | |
_printUsage | |
exit 1 | |
fi | |
sudo netstat -ltnp | head -n 2; sudo netstat -ltnp | grep -w ":$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment