Skip to content

Instantly share code, notes, and snippets.

@smijar
Created April 23, 2020 04:54
Show Gist options
  • Save smijar/bbc9f9bcda471621fabbd467457516da to your computer and use it in GitHub Desktop.
Save smijar/bbc9f9bcda471621fabbd467457516da to your computer and use it in GitHub Desktop.
OS X process on which port
lsof -iTCP -sTCP:LISTEN -n -P
# utility function
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