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)

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 ../../
$ cd /var
or now:
$ aa 2


[admin@linux1 html]$ pwd

[admin@linux1 html]$ aa 2

So handy.