Skip to content

Instantly share code, notes, and snippets.

@renkin
Created July 8, 2022 06:57
Show Gist options
  • Save renkin/a664a96d489aaeb1bf75c9938d02b503 to your computer and use it in GitHub Desktop.
Save renkin/a664a96d489aaeb1bf75c9938d02b503 to your computer and use it in GitHub Desktop.
Greps for a port in netstat output
#!/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