Created
April 4, 2019 15:05
-
-
Save bitmvr/733debd3fc1428e5a10e668b2d303a7f to your computer and use it in GitHub Desktop.
Current Working Directory Monitor
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
| #!/usr/bin/env bash | |
| function cwdmon::getPIDsByAppName(){ | |
| appName="${1}" | |
| pgrep -a $appName | |
| } | |
| function cwdmon::getAllCWDs(){ | |
| for PID in $(cwdmon::getPIDsByAppName 'bash'); do | |
| lsof -p "$PID" | grep -i "cwd" | awk '{ print $9}' | |
| done | |
| } | |
| cwdmon::getAllCWDs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment