Original author(s) | Bill Joy |
---|---|
Developer(s) | Various open-source and commercial developers |
Operating system | Unix, Unix-like, DOS, Windows, ReactOS |
Platform | Cross-platform |
Type | Command |
In computing, pushd
and popd
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. [1] [2]
They are widely available as builtin commands in many command-line interpreters, such as 4DOS, Bash, [3] C shell, tcsh, Hamilton C shell, KornShell, cmd.exe and PowerShell, and for various operating systems including both Windows and Unix-like systems.
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 dirs
in Unix or Get-Location -stack
in PowerShell. The current working directory is always at the top of the stack.
The pushd
('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 pushd
is not provided with a path argument, it changes instead to the next directory from the top of the stack,[ clarification needed ] which can be used to toggle between two directories.
The popd
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. [4] [5]
The first Unix shell to implement a directory stack was Bill Joy's C shell.[ citation needed ] The syntax for pushing and popping directories is essentially the same as that used now. [6] [7]
Both commands are available in FreeCOM, the command-line interface of FreeDOS. [8]
In Windows PowerShell, pushd is a predefined command alias for the Push-Location
cmdlet and popd is a predefined command alias for the Pop-Location
cmdlet. Both serve basically the same purpose as the pushd
and popd
commands.
[user@server /usr/ports] $ pushd/etc /etc /usr/ports[user@server /etc] $ popd/usr/ports[user@server /usr/ports] $
C:\Users\root>pushd C:\Users C:\Users>popdC:\Users\root>
@echo off rem This batch file deletes all .txt files in a specified directorypushd%1del *.txt popdecho All text files deleted in the %1 directory
pushd [path | ..]
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
The cd
command, also known as chdir
, is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files.
In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with the process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just current directory. When a process refers to a file using a simple file name or relative path (as opposed to a file designated by a full path from a root directory), the reference is interpreted relative to the working directory of the process. So for example a process with working directory /rabbit-shoes that asks to create the file foo.txt will end up creating the file /rabbit-shoes/foo.txt.
In Unix-like and some other operating systems, the pwd
command writes the full pathname of the current working directory to the standard output.
In computing, a command is a directive to a computer program to perform a specific task. It may be issued via a command-line interface or as input to a network service as part of a network protocol, or as an event triggered in a graphical user interface.
An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.
A path is a string of characters used to uniquely identify a location in a directory structure. It is composed by following the directory tree hierarchy in which components, separated by a delimiting character, represent each directory. The delimiting character is most commonly the slash ("/"), the backslash character ("\"), or colon (":"), though some operating systems may use a different delimiter. Paths are used extensively in computer science to represent the directory/file relationships common in modern operating systems and are essential in the construction of Uniform Resource Locators (URLs). Resources can be represented by either absolute or relative paths.
In computer programming, glob patterns specify sets of filenames with wildcard characters. For example, the Unix Bash shell command mv *.txttextfiles/
moves all files with names ending in .txt
from the current directory to the directory textfiles
. Here, *
is a wildcard and *.txt
is a glob pattern. The wildcard *
stands for "any string of any length including empty, but excluding the path separator characters ".
Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows, and ReactOS operating systems. On Windows CE .NET 4.2, Windows CE 5.0 and Windows Embedded CE 6.0 it is referred to as the Command Processor Shell. Its implementations differ between operating systems, but the behavior and basic set of commands are consistent. cmd.exe is the counterpart of COMMAND.COM in DOS and Windows 9x systems, and analogous to the Unix shells used on Unix-like systems. The initial version of cmd.exe for Windows NT was developed by Therese Stowell. Windows CE 2.11 was the first embedded Windows release to support a console and a Windows CE version of cmd.exe. The ReactOS implementation of cmd.exe is derived from FreeCOM, the FreeDOS command line interpreter.
A command shell is a command-line interface to interact with and manipulate a computer's operating system.
In computing, tee
is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input. It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.
In computing, alias is a command in various command-line interpreters (shells), which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. alias
is available in Unix shells, AmigaDOS, 4DOS/4NT, FreeDOS, KolibriOS, Windows PowerShell, ReactOS, and the EFI shell. Aliasing functionality in the MS-DOS and Microsoft Windows operating systems is provided by the DOSKey command-line utility.
A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF
, FOR
, and GOTO
labels. The term "batch" is from batch processing, meaning "non-interactive execution", though a batch file might not process a batch of multiple data.
In computing, move
is a command in various command-line interpreters (shells) such as COMMAND.COM
, cmd.exe
, 4DOS/4NT, and PowerShell. It is used to move one or more files or directories from one place to another. The original file is deleted, and the new file may have the same or a different name. The command is analogous to the Unix mv
command and to the OpenVOS move_file
and move_dir
commands.
In computing, ren
is a command in various command-line interpreters (shells) such as COMMAND.COM
, cmd.exe
, 4DOS, 4NT and Windows PowerShell. It is used to rename computer files and in some implementations also directories. It is analogous to the Unix mv
command. However, unlike mv
, ren
cannot be used to move files, as a new directory for the destination file may not be used. Alternatively, move
may be used if available. On versions of MS-DOS that do not support the move
command, the user would simply copy the file to a new destination, and then delete the original file. A notable exception to this rule is DOSBox, in which ren
may be used to move a file, since move
is not supported.
In computing, find
is a command in the command-line interpreters (shells) of a number of operating systems. It is used to search for a specific text string in a file or files. The command sends the specified lines to the standard output device.
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.
In computing, title
is a command in various command-line interpreters (shells) on Microsoft Windows and ReactOS that changes the title for the graphical terminal emulator window. The command is also used within DFS and ADFS to change the title of the disc in the current drive.
In computing, start
is a command of the IBM OS/2, Microsoft Windows and ReactOS command-line interpreter cmd.exe to start programs or batch files or to open files or directories using the default program. start
is not available as a standalone program. The underlying Win32 API is ShellExecute
.
A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.
In computing, findstr is a command in the command-line interpreters (shells) of Microsoft Windows and ReactOS. It is used to search for a specific text string in computer files.