Skip to content

It’s the little things: cd –

06/04/2012

If you work with Unix then you will at some stage have to move between two directories constantly looking at data in one and comparing it to the other.  If you have to do this constantly it gets a bit/very annoying.  You open a second window and go to the second directory but then you have to click on that window to use it and then click back on the other window to use that one, then you mistakenly right click the mouse and a load of commands you had copied get run and Ahhhhh stop! there has to be an easier way.

There is, it is the command cd – that’s it.  No more scrolling through bash, no more copy and pasting, simply type cd – and it will go back to the last directory.  How?  There is a parameter called OLDPWD saved in your .profile file which usefully saves the last path you were on before this one and cd – calls it.

I suppose while I’m on the topic of cd shortcuts I’ll mention a few others.

cd ~ go to your home directory

cd ~sometulip go to sometulips home directory

cd .. go back one directory

I hope this helps you save some sanity and time

Advertisements

From → Uncategorized

3 Comments
  1. Mur permalink

    Just log a track with the UNIX team. We’ll eventually get you out of there. 🙂

  2. Mur permalink

    P.S. no one needs a mouse… Ctrl-tab rotates between current and previously used window. If you liked cd -, this will blow your fucking mind.

  3. Is that alt-tab on windows? I can’t get ctrl-tab to work on putty. On an unexpected note ctrl -tab works on firefox to allow you to scroll through your opened tabs 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: