Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save runnerdave/516550781e2a5fea83686a0076a4140e to your computer and use it in GitHub Desktop.
Save runnerdave/516550781e2a5fea83686a0076a4140e to your computer and use it in GitHub Desktop.
lsof function for .bash_profile
# example usage:
# listening 22
# listening java
listening() {
if [ $# -eq 0 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P
elif [ $# -eq 1 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
else
echo "Usage: listening [pattern]"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment