Skip to content

Instantly share code, notes, and snippets.

@RatoX
Last active September 25, 2018 00:20
List all ports used by your user with the process name
#!/bin/bash
# This is in progress I tested it only on macOS 10.13.6
# outuput e.g:
# PID (319) Spotify -> :57621
function ports {
PORTS=$(lsof -iTCP -sTCP:LISTEN -nP)
echo "$PORTS" | awk 'match($9, /[\]|\*]+:(.*)$/) { print " PID ("$2") "$1" -> "substr($9, RSTART+1, RLENGTH-1) }'
}
@RatoX
Copy link
Author

RatoX commented Sep 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment