Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Jun 4 '13 at 1:41

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

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

You must log in to answer this question.

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