Skip to content

Instantly share code, notes, and snippets.

@dims
Created August 13, 2024 01:05
Show Gist options
  • Save dims/d8069b1c27409f9130f815bc6075ee2d to your computer and use it in GitHub Desktop.
Save dims/d8069b1c27409f9130f815bc6075ee2d to your computer and use it in GitHub Desktop.
Shows the name of the command running on each port on MacOS
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment