Created
July 1, 2024 21:03
-
-
Save aflansburg/5b505b2d9801fdff1b629b806fb306de to your computer and use it in GitHub Desktop.
"wport" - tells you ports that are LISTENing or checks a specific port
This file contains 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
# add to ~/.zhsrc | |
# run source ~/.zshrc | |
# run w/ `wport` or `wport <port>` | |
function wport(){ | |
if [ "$1" = "help" ] || [ "$1" = "-h" ]; then | |
echo "Usage: wport [port]" | |
echo "Without a port argument, list all ports that are currently being listened to." | |
echo | |
echo "If a port is provided, list only the port that is being listened to." | |
echo | |
return | |
fi | |
if [ -z "$1" ]; then | |
lsof -i -P | grep -e "LISTEN" | |
else | |
lsof -i -P | grep -e "$1.*LISTEN" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment