Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pwdx for mac. Usage: pwx pid
function pwdx {
lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $NF}'
}
@jbyler

This comment has been minimized.

Copy link

@jbyler 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

This comment has been minimized.

Copy link

@varenc varenc commented May 24, 2021

thanks!

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