Last active
September 25, 2018 00:20
-
-
Save RatoX/ba1588e5fc284de9140ae263dc45bc16 to your computer and use it in GitHub Desktop.
List all ports used by your user with the process name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) }' | |
} |
Author
RatoX
commented
Sep 20, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment