Skip to content

Instantly share code, notes, and snippets.

@RatoX
Last active September 25, 2018 00:20
Show Gist options
  • Save RatoX/ba1588e5fc284de9140ae263dc45bc16 to your computer and use it in GitHub Desktop.
Save RatoX/ba1588e5fc284de9140ae263dc45bc16 to your computer and use it in GitHub Desktop.
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

screen recording 2018-09-20 at 11 09 am

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