Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

pushd and popd

From Wikipedia, the free encyclopedia
Shell commands to save and restore the working directory
pushd & popd
Original authorBill Joy
DevelopersVariousopen-source andcommercial developers
Operating systemUnix,Unix-like,DOS,Windows,ReactOS
PlatformCross-platform
TypeCommand
A diagram showing a vertical stack of identically-sized rectangles, representing the stack. An additional rectangle of the same type is shown on the left with an arrow indicating it being added to the stack, marked 'push'. A corresponding rectangle on the right, being removed from the top, is marked 'pop'.
Directory paths stack. Elements are pushed onto and popped from the top.

pushd andpopd areshellcommands that together allow the user to revert to a previousworking directory via the command line. They use astackdata structure for directory paths.pushd pushes the working directory path onto the stack and changes to the specified directory, andpopd pops the most recent item from the stack and changes directory to the popped value.[1][2][3][4]

Behavior varies if no argument is passed topushd. On Unix, the command swaps the top two directories on the stack, which toggles between them. On Windows, the command lists the paths in the stack except for the current one.

The commands are widely available asbuiltin commands in many shells, such asBash,[5]Command Prompt,PowerShell,C shell,tcsh,4DOS,Hamilton C shell,KornShell, andFreeCOM.[6]

The stack of directory paths can be displayed via thedirs Unix command orGet-Location -stack PowerShell command. The working directory is at the top of the stack.

The firstUnix shell to provide a directory stack was Bill Joy'sC shell.[citation needed] The syntax for pushing and popping directories is essentially the same as that used now.[7][8]

Examples

[edit]

Unix-like

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

Command Prompt and ReactOS

[edit]
C:\Users\root>pushd C:\UsersC:\Users>popdC:\Users\root>

See also

[edit]

References

[edit]
  1. ^Pushd - change directory/folder - Windows CMD - SS64.com
  2. ^Popd - Windows CMD - SS64.com
  3. ^Microsoft TechNet Pushd article
  4. ^Microsoft TechNet Popd article
  5. ^Bash Reference Manual: Directory Stack Builtins
  6. ^"FreeCOM - FreeDOS". Archived fromthe original on 2021-05-08. Retrieved2019-07-25.
  7. ^Chapter 14 – 14.6 The Shells' pushd and popd Commands
  8. ^man tcsh"TCSH(1)". Archived fromthe original on 2014-03-10. Retrieved2014-11-03.

Further reading

[edit]

External links

[edit]
Wikibooks has a book on the topic of:Guide to Windows Commands
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
Ecosystem
Interpreters
Terminals
File system navigation
File management
Archiving
Disk management
Processes
Registry
User environment
File contents
Scripting
Networking
Maintenance and care
Boot management
Software development
Miscellaneous
Retrieved from "https://en.wikipedia.org/w/index.php?title=Pushd_and_popd&oldid=1314541636"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp