Skip to content

Instantly share code, notes, and snippets.

@patoi
Created August 13, 2024 14:16
Show Gist options
  • Save patoi/b25ea4fa5c31ca5a2aac467483f972d1 to your computer and use it in GitHub Desktop.
Save patoi/b25ea4fa5c31ca5a2aac467483f972d1 to your computer and use it in GitHub Desktop.
MacOS list command's name by port
sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | while read port process pid; do echo "Port $port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n
# by Laurie Voss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment