Created
April 9, 2021 14:18
-
-
Save banjeremy/29c80492ac4511b26133002854bff307 to your computer and use it in GitHub Desktop.
get pid for a process running on a 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
whatsonport () { | |
if [ $# -eq 1 ] | |
then | |
lsof -i :$1 | awk '{ print $2; }' | head -n 2 | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} -v PID | |
else | |
echo "Usage: whatsonport [port]" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment