⊙ AntiQuark

Truth, Beauty, Charm, Strange


bash shell tip: cd -

Bash shell tip of the decade: if you type

cd -

(That's a hyphen after the cd) you'll switch to the previous directory you were in. Type it again and you'll return to the directory you just left.

If I had known that five years ago, it would have saved me 10,000 hours of typing by now.


  • At 10/27/2008 3:54 PM, Blogger butch said…

    I like this command, but how do you suppress its displaying the directory you are going to.

    Given that:

    pwd is x/y/z

    and I do "cd k"

    then "cd -"

    the command displays "x/y/z"

    I do not want my script that uses "cd -" to display anyting.

    How do you suppress the output?

  • At 10/27/2008 4:57 PM, Blogger Derek said…


    cd - > /dev/null


Post a Comment

<< Home