Pushd及popd
原作者 | Bill Joy |
---|---|
開發者 | 多位开源软件及商业软件开发者 |
操作系统 | Unix, Unix-like, DOS, Windows, ReactOS |
平台 | 跨平台 |
类型 | 命令 |
pushd
与 popd
是用于操作命令行目录栈的命令。[1][2]它们在DOS、Microsoft Windows、ReactOS[3]和Unix-like等系统上的4DOS、Bash、[4]C shell、tcsh、Hamilton C shell、KornShell、cmd.exe和PowerShell等命令行解释器中可用。
概览
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下,pushd 是Push-Location
cmdlet预定义的alias,popd 是Pop-Location
cmdlet预定义的alias。两者与pushd
、popd
命令功能基本相同。
语法
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
另请参阅
参考文献
- ^ Pushd - change directory/folder - Windows CMD - SS64.com. [2021-05-05]. (原始内容存档于2021-05-07).
- ^ Popd - Windows CMD - SS64.com. [2021-05-05]. (原始内容存档于2021-05-06).
- ^ https://github.com/reactos/reactos/blob/master/base/shell/cmd/dirstack.c
- ^ Bash Reference Manual: Directory Stack Builtins. [2021-05-05]. (原始内容存档于2021-02-26).
- ^ Microsoft TechNet Pushd article. [2021-05-05]. (原始内容存档于2018-02-03).
- ^ Microsoft TechNet Popd article. [2021-05-05]. (原始内容存档于2018-02-03).
- ^ Chapter 14 – 14.6 The Shells' pushd and popd Commands. [2021-05-05]. (原始内容存档于2020-12-03).
- ^ man tcsh TCSH(1). [2014-11-03]. (原始内容存档于2014-03-10).
- ^ FreeCOM - FreeDOS. [2021-05-05]. (原始内容存档于2021-05-08).
更多资料
- Frisch, Æleen. Windows 2000 Commands Pocket Reference. O'Reilly. 2001. ISBN 978-0-596-00148-3.
- McElhearn, Kirk. The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. 2006. ISBN 978-0470113851.
外部链接
維基教科書中的相關電子教程:Guide to Windows Commands
- 查
- 论
- 编
- awk
- banner(英语:banner (Unix))
- basename
- comm(英语:comm)
- csplit(英语:csplit)
- cut
- diff
- dirname
- ed
- ex
- fmt(英语:fmt)
- fold(英语:fold (Unix))
- head(英语:head (Unix))
- iconv
- join(英语:join (Unix))
- less
- more
- nl(英语:nl (Unix))
- paste(英语:paste (Unix))
- sed
- sort(英语:sort (Unix))
- spell(英语:spell (Unix))
- strings(英语:strings (Unix))
- tail
- tr
- uniq(英语:uniq)
- vi
- wc
- xargs
- alias
- echo
- printf格式字符串
- test(英语:test (Unix))
- unset
- wait
- apropos(英语:apropos (Unix))
- help(英语:help (command))
- man
|