Contents
Pushd and popd
In**** computing, ******** ******** and ******** ******** are a pair of commands which allow users to quickly switch between the current and previous directory when using the command ****line. When called, they use a directory stack to sequentially save and retrieve directories visited by the user. They are widely available as builtin commands in many command-line interpreters, such as 4DOS, Bash, C shell, tcsh, Hamilton C shell, KornShell, cmd.exe and PowerShell, and for various operating systems including both Windows and Unix-like systems.
Overview
The directory stack underlies the functions of these two commands. It is an array of paths stored as an environment variable in the CLI, which can be viewed using the command in Unix or in PowerShell. The current working directory is always at the top of the stack. The ('push directory') command saves the current working directory to the stack then changes the working directory to the new path input by the user. If is not provided with a path argument, it changes instead to the next directory from the top of the stack, which can be used to toggle between two directories. The command removes (or 'pops', in the stack analogy) the current path entry from the stack and returns to the path at the top of the stack as the new working directory. The first Unix shell to implement a directory stack was Bill Joy's C shell. The syntax for pushing and popping directories is essentially the same as that used now. Both commands are available in FreeCOM, the command-line interface of FreeDOS. In Windows PowerShell, pushd is a predefined command alias for the cmdlet and popd is a predefined command alias for the cmdlet. Both serve basically the same purpose as the and commands.
Examples
Unix-like
Microsoft Windows and ReactOS
CMD batch file
Syntax
pushd
pushd [path | ..] Arguments:
popd
popd
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.