In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, e ...
,
pushd
and
popd
are
commands used to work with the
command line directory
stack
Stack may refer to:
Places
* Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group
* Blue Stack Mountains, in Co. Donegal, Ireland
People
* Stack (surname) (including a list of people ...
. They are available on
command-line interpreters such as
4DOS
4DOS is a command-line interpreter by JP Software, designed to replace the default command interpreter COMMAND.COM in Microsoft DOS and Windows. It was written by Rex C. Conn and Tom Rawson and first released in 1989. Compared to the default, ...
,
Bash
Bash or BASH may refer to:
Arts and entertainment
* ''Bash!'' (Rockapella album), 1992
* ''Bash!'' (Dave Bailey album), 1961
* '' Bash: Latter-Day Plays'', a dramatic triptych
* ''BASH!'' (role-playing game), a 2005 superhero game
* "Bash" ('' ...
,
C shell,
tcsh,
Hamilton C shell
Hamilton C shell is a clone of the Unix C shell and utilities
Early
for Microsoft Windows created by Nicole Hamilton at Hamilton Laboratories as a completely original work, not based on any prior code. It was first released on OS/2 on Dece ...
,
KornShell
KornShell (ksh) is a Unix shell which was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. The initial development was based on Bourne shell source code. Other early contributors were Bell ...
,
cmd.exe, and
PowerShell for operating systems such as
Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
systems.
Overview
The
pushd
command saves the current
working directory in memory so it can be returned to at any time,
pushd
moves to the parent directory. The
popd
command returns to the
path
A path is a route for physical travel – see Trail.
Path or PATH may also refer to:
Physical paths of different types
* Bicycle path
* Bridle path, used by people on horseback
* Course (navigation), the intended path of a vehicle
* Desire p ...
at the top of the directory stack. This directory stack is accessed by the command
dirs
in Unix or
Get-Location -stack
in Windows PowerShell.
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.
FreeCOM - FreeDOS
/ref>
In Windows PowerShell
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-sourc ...
, ''pushd'' is a predefined command alias for the Push-Location
cmdlet
PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language. Initially a Windows component only, known as Windows PowerShell, it was made open-sourc ...
and ''popd'' is a predefined command alias for the Pop-Location
cmdlet. Both serve basically the same purpose as the pushd
and popd
commands.
Syntax
Pushd
pushd ..
Arguments:
*path
This optional command-line argument specifies the directory to make the current directory. If path
is omitted, the path at the top of the directory stack is used, which has the effect of toggling between two directories.
Popd
popd
Examples
Unix-like
ser@server /usr/ports$ pushd /etc
/etc /usr/ports
ser@server /etc$ popd
/usr/ports
ser@server /usr/ports$
Microsoft Windows and ReactOS
C:\Users\root>pushd C:\Users
C:\Users>popd
C:\Users\root>
CMD batch file
@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
See also
* List of DOS commands
* List of Unix commands
References
Further reading
*
*
External links
pushd , Microsoft Docs
popd , Microsoft Docs
Internal DOS commands
Microcomputer software
ReactOS commands
Windows administration
Computing commands
{{windows-stub