-
-
Save cmj/2bfa8f7a71bbf32041c4e07586f7fcbe to your computer and use it in GitHub Desktop.
Show working directory of process listening on port number
This file contains hidden or 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 | |
| if [[ -z $1 ]]; then echo "$0 <port> # show cwd and process listening on port"; exit 1; fi | |
| sudo lsof -w -a -p $(lsof -iTCP:$1 -sTCP:LISTEN | awk 'NR>1 {print $2}') -d cwd 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment