Skip to content

Instantly share code, notes, and snippets.

@bitmvr
Created April 4, 2019 15:05
Show Gist options
  • Select an option

  • Save bitmvr/733debd3fc1428e5a10e668b2d303a7f to your computer and use it in GitHub Desktop.

Select an option

Save bitmvr/733debd3fc1428e5a10e668b2d303a7f to your computer and use it in GitHub Desktop.
Current Working Directory Monitor
#!/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