Tag Archives: function

cd ../../../ … ugh.

I picked a shortcut, called: aa

Then, in ~/.bashrc (my .bashrc), I created a function:

function aa
{
cd $(for ((i=0 ; i<$1 ;i++)); do printf "../" ; done)
pwd
}

This will allow you to ‘cd’ back X number of directories by issuing: aa X (where X is a number of directories you wanna go backwards).

So … say I’m in /var/www/html/ and I want to go back 2 levels to /var
I could:

$ cd ../../
or:
$ cd /var
or now:
$ aa 2

Example:

[admin@linux1 html]$ pwd
/var/www/html

[admin@linux1 html]$ aa 2
/var

So handy.