Next heavyweight configuration command in Linux: configuration of global variables in cdpath
Author: Yu Chao Email: yuchao86@gmail.com
The following is a translation based on the book linix 101 hacks,
I hope you will give me more comments. If you have a better way, please post your comments or send me an email,
If you often use the CD command to a sub-directory or a special parent directory, you can set the global variable cdpath
Specify the sub-directory or special parent directory to which the path is to be sent, without providing an absolute path name.
Example:
Yuchao @ yuchao-Latitude-E5410 :~ $ Pwd
/Home/yuchao
Yuchao @ yuchao-Latitude-E5410 :~ $ CD mail
-Bash: CD: Mail: no such file or directory
[Note: this is looking for mail directory under current
Directory]
Yuchao @ yuchao-Latitude-E5410 :~ $ Export cdpath = .:~ :/Etc:/var:/usr/local
Yuchao @ yuchao-Latitude-E5410 :~ $ CD mail
/Var/mail
@ Yuchao-Latitude-E5410:/var/mail $ pwd
/Var/mail
Yuchao @ yuchao-Latitude-E5410:/var/mail $
[Note: this is looking for mail under/Var and not
Under current directory]
@ Yuchao-Latitude-E5410:/var/mail $ pwd
/Var/mail
to enable the configuration to take effect upon startup, run the configuration command export cdpath = .:~ :/Etc:/var:/usr/local add to your configuration file
~ /. Bash_profile or ~ /. Bashrc, or the global/etc/profile configuration file.
this command is useful for engineers who have set the home working directory, such as your $ java_home, $ tomcat_home, $ ORACLE_HOME, and $ path,
you can add them to this global variable, and then you can directly CD them to the directory you want to go to. It's hack !!
Linux 101 hacks
www.thegeekstuff.com