I can ps -x to get a list then grep the name then manually type in the process number to lsof -p to list the processes open file locations and get the cwd of the process ... whew! all this manual work. is there a way to say "go to process location" ?

  • 1
    cwd is not necessarily the process location - What exactly are you after? Most Apps will start with current directory of /
    – mmmmmm
    Oct 26, 2017 at 19:42

1 Answer 1


Not aware of such a function, yet that doesn't mean it doesn't exist.

However, I'm guessing you could simply program it into bashrc? It shouldn't be too hard to make a manual command for this..

For example by adding something like this function to your .bashrc:

function showp() {
    pid=$(ps -x | grep -i $1 | awk '{print $1}' | head -1)
    dir=$(lsof -p $pid | grep cwd | awk '{print $9}')
    cd $dir
    echo "Now arrived here: " $(pwd) 

Then (after sourcing bashrc of course) simply type (for example): showp safari and it will output:

Now arrived here:  /

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .