热门问题
时间线
聊天
视角

pushd及popd

来自维基百科,自由的百科全书

Remove ads

pushdpopd 是用於操作命令行目錄命令[1][2]它們在DOSMicrosoft WindowsReactOS[3]Unix-like等系統上的4DOSBash[4]C shelltcshHamilton C shellKornShellcmd.exePowerShell命令行解釋器中可用。

快速預覽 原作者, 開發者 ...

概覽

pushd命令將當前工作目錄存儲到內存中,以便隨時返回。popd命令返回目錄棧頂的路徑[5][6]此目錄棧由Unix命令dirs或 Windows PowerShell的Get-Location -stack訪問。

第一個實現目錄棧的Unix shell是Bill Joy的C shell。這套Shell下將目錄壓棧、出棧的語法與現在基本相同。[7][8]

這兩個命令都在FreeCOM——即FreeDOS的命令行界面——可用。[9][來源可靠?]

Windows PowerShell下,pushdPush-Locationcmdlet預定義的aliaspopdPop-Locationcmdlet預定義的alias。兩者與pushdpopd命令功能基本相同。

語法

Pushd

pushd [path | ..]

參數:

  • 可選命令行參數path指定即將成為「當前目錄」的目錄。如果path被省略,則會使用目錄棧頂的路徑,產生在兩個目錄之間切換的效果。

Popd

popd

示例

Unix-like

[user@server /usr/ports] $ pushd /etc
/etc /usr/ports
[user@server /etc] $ popd
/usr/ports
[user@server /usr/ports] $

Microsoft Windows與ReactOS

C:\Users\root>pushd C:\Users
C:\Users>popd
C:\Users\root>

DOS批處理文件

@echo off
rem This batch file deletes all .txt files in a specified directory
pushd %1
del *.txt
popd
echo All text files deleted in the %1 directory

另請參閱

參考文獻

Loading content...

更多資料

Loading content...

外部連結

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads