Skip to content

Instantly share code, notes, and snippets.

@siberex
Created August 13, 2024 15:10
Show Gist options
  • Save siberex/cd095024277c222781a6ca1bd443c8c0 to your computer and use it in GitHub Desktop.
Save siberex/cd095024277c222781a6ca1bd443c8c0 to your computer and use it in GitHub Desktop.
macos_open_ports.sh
# https://x.com/seldo/status/1823126087423099192
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