Saturday, December 3, 2011

CDPATH defines base directory for cd command

ubuntu1004@ubuntu1004:~$ pwd
/home/ubuntu1004
ubuntu1004@ubuntu1004:~$ cd init.d
bash: cd: init.d: No such file or directory
ubuntu1004@ubuntu1004:~$ export CDPATH=/etc
ubuntu1004@ubuntu1004:~$ cd init.d
/etc/init.d
ubuntu1004@ubuntu1004:/etc/init.d$ pwd
/etc/init.d
ubuntu1004@ubuntu1004:/etc/init.d$

- change permanent, add export CDPATH=/etc to your ~/.bash_profile
- you can add more than one directory entry in the CDPATH variable, separating them with ':' 
export CDPATH=.:~:/etc:/var

No comments:

Post a Comment