Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Created July 29, 2022 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgriffs/95ad28532f29cd5767585e99343cf5d8 to your computer and use it in GitHub Desktop.
Save kgriffs/95ad28532f29cd5767585e99343cf5d8 to your computer and use it in GitHub Desktop.
macOS port listening bash
# https://stackoverflow.com/a/30029855/21784
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