Skip to content

Instantly share code, notes, and snippets.

@lukaszx0
Last active February 1, 2016 22:50
Show Gist options
  • Save lukaszx0/d23b50f5b9e3fa91fd29 to your computer and use it in GitHub Desktop.
Save lukaszx0/d23b50f5b9e3fa91fd29 to your computer and use it in GitHub Desktop.
pid to port
#!/bin/bash
# Prints ports used by given process (PID)
#
# Usage:
# pid2port 123
function pid2port() {
lsof -Pan -p $1 -i | awk '{print $1,$3,$4,$8,$9}'
}
~/Development/foobar> pid2port 1687
COMMAND USER FD NODE NAME
java lukasz 27u TCP 127.0.0.1:59906->127.0.0.1:25101
java lukasz 29u TCP *:22299
java lukasz 30u TCP *:22280
java lukasz 43u TCP *:22243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment