Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After I do

$ which play
$ /Users/username/local/play/play

Is there a way that I can access the shown directory quickly without manually typing the directory by hand? Just curious :)

share|improve this question

migrated from stackoverflow.com Jun 4 '13 at 1:41

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 5 down vote accepted
cd $(dirname $(which play))

Or, immediately after running which play, you can do:

cd $(dirname $(!!))
share|improve this answer
5  
Just to clarify, !! does not print the output of the previous command, but actually reruns the previous command. So if you try this trick for a command with side effects or non-constant behavior, you might get unexpected results –  Lorkenpeist Jun 4 '13 at 0:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.