Change Directory with two dots (cd..)

Mike Kenny inzanix at gmail.com
Wed Apr 26 12:38:49 UTC 2006


On 4/26/06, Chris Neary <hello at poetofcode.org> wrote:
> On a related note, is it the hyphen which is used with cd to 'ping-pong'
> between current and previous-visited directories? I think I read this in
> Linux Desktop Hacks, but can't remember it now.
>
> cd htdocs
> dir: htdocs
> cd ~
> dir: /home/$USER
> cd -
> dir: htdocs
>
> Is that right? A much underused and not-well-known time-saving feature. If I
> could actually remember to use it myself maybe I'd have a point here.
$ cd -
this will return you to the previous directory i.e. before your last cd command.

Noting your comments about typing, you may not like this one
$ cd ~-
as it has an extra character to achieve the same thing, but also
noting that you had forgotten (?) 'cd -' you may want to consider this
as you can use the value ~- in a script (e.g. echo just left directory
~-). So getting used to this saves you remembering both :-)




More information about the ubuntu-users mailing list