Thursday, June 24, 2010

The cool cd terminal hack

Method One: Navigate up the directory using “..n”

In the example below, ..4 is used to go up 4 directory level, ..3 to go up 3 directory level, ..2 to go up 2 directory level.

Add the following alias to your ~/.bashrc and re-login.

alias ..="cd .."

alias ..2="cd ../.."

alias ..3="cd ../../.."

alias ..4="cd ../../../.."

alias ..5="cd ../../../../.."

Method Two: Navigate up the directory using only dots

In the example below, ….. (five dots) is used to go up 4 directory level. Typing 5 dots to go up 4 directory structure is really easy to remember, as when you type the first two dots, you are thinking “going up one directory”, after that every additional dot, is to go one level up. So, use …. (four dots) to go up 3 directory level and .. (two dots) to go up 1 directory level.

Add the following alias to your ~/.bashrc and re-login for the ….. (five dots) to work properly.

alias ..="cd .."

alias ...="cd ../.."

alias ....="cd ../../.."

alias .....="cd ../../../.."

alias ......="cd ../../../../.."

THANKS: Linux Tips & The Geek Stuff

(For two other methods, check out The Geek Stuff, and while you at it, read the best posting yet on RTFM)

No comments:

Post a Comment