LINUX 下一個重量級的配置命令:CDPATH全域變數的配置(原創)

來源:互聯網
上載者:User

LINUX 下一個重量級的配置命令:CDPATH全域變數的配置
作者:餘超 email:yuchao86@gmail.com

如下是根據《Linix 101 Hacks》這本書裡面的來翻譯整理的,
希望大家多多提意見,如果你有更好的方法請發表看法或者回郵件給我,

如果你經常使用cd 命令到一個子目錄或者是一個特殊父目錄,你可以設定全域變數CDPATH
指定到要到的子目錄或是特殊的父目錄,而不用給出絕對的路徑名稱。
執行個體如下:
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@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@yuchao-Latitude-E5410:/var/mail$ pwd
/var/mail

要使這樣的配置開機生效你把配置命令 export CDPATH=.:~:/etc:/var:/usr/local 添加到你的設定檔
~/.bash_profile或者~/.bashrc ,或者是全域的/etc/profile設定檔中。
這個命令對於有設定HOME工作目錄的工程師很有用,比如你的$JAVA_HOME,$TOMCAT_HOME,$ORACLE_HOME和$PATH等等,
你都可以添加到這個全域變數中,之後就可以直接cd到想要去的目錄了,很hack吧!!
Linux 101 Hacks
www.thegeekstuff.com

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.