Skip to content

Instantly share code, notes, and snippets.

@tobym
Created October 27, 2010 01:03
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save tobym/648188 to your computer and use it in GitHub Desktop.
Save tobym/648188 to your computer and use it in GitHub Desktop.
pwdx for mac. Usage: pwx pid
function pwdx {
lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $NF}'
}
@jbyler
Copy link

jbyler commented May 10, 2018

A variant that uses lsof's machine-readable format and works properly when the directory name has spaces in it:

function pwdx {
  lsof -a -d cwd -p $1 -n -Fn | awk '/^n/ {print substr($0,2)}'
}

@varenc
Copy link

varenc commented May 24, 2021

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment