linux中利用Pushd/popd頻繁切換目錄

常言道:『飲水思源』,在 Open Source 的世界裡,我們常常需要別人的幫助,但是在您有所心得的時候請記得分享給大家,『幫助人是快樂的喔』。歡迎您在使用 debian 的過程中的任何心得分享給大家。

linux中利用Pushd/popd頻繁切換目錄

文章sppmg » 週六 9月 29, 2007 5:37 pm

當然啦!
這較適合用在很不相關的目錄,否則cd ..就可以了。

相關指令:
pushd 若有參數就跳到那個目錄,並將原目錄壓入堆棧。若無參數便回到上一個目錄,並將堆棧中最近的兩個目錄交換。
popd 若無參數就回到上一個目錄且彈出堆棧中最近的目錄。若有參數則僅僅彈出堆棧中最底層的目錄。(工作目錄不變)
dirs 列出堆棧中的目錄。

這些指令為bash內建指令!其他shell請自行研究!!

實例:

pushd:

Debian:~$ dirs
~
Debian:~$ pushd /etc
/etc ~
Debian:/etc$ pushd /home
/home /etc ~
-----------------(無參數)----------------
Debian:/home$ pushd
/etc /home ~
Debian:/etc$ pushd
/home /etc ~

dirs:

Debian:/home$ dirs
/home /etc ~


popd:

Debian:/home$ popd
/etc ~
Debian:/etc$ popd
~
------------------------(有參數)--------------------
Debian:/bin$ dirs
/bin /etc ~ /home
Debian:/bin$ popd /etc
/bin /etc ~
Debian:/bin$ popd
/etc ~
Debian:/etc$ popd 8
/etc
系統的威力來自於程式的相互關係, 而非來自程式本身
is the idea that the power of a system comes more from the relationships among programs than from the programs themselves.

(英文語法怪怪的......誰能提供完整的版本?)
sppmg
活潑的高中生
活潑的高中生
 
文章: 317
註冊時間: 週五 8月 04, 2006 3:47 pm
來自: 臺灣

回到 share

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客