Pwd
Template:Short description
{{#invoke:other uses|otheruses}}
Template:Lowercase
{{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1
| unknown = Template:Main other
| preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y
| AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid
}}Template:Main other
pwd
(print working directory)<ref name="minix">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="linux">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="gnu">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> is shell command that reports the working directory path to standard output.<ref name="unix">Template:Cite book</ref><ref name="plan9">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="posix">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="dec">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="apple">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="bsd">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref name="solaris">{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref>
Although often associated with Unix, its predecessor Multics had a pwd
command (which was a short name of the print_wdir
command<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref>) from which the Unix command originated.<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> The command is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification.<ref>Template:Man</ref> It appeared in Version 5 Unix.<ref>Template:Man</ref> The version bundled in GNU Core Utilities was written by Jim Meyering.<ref>Template:Man</ref>
The command is available in other shells and operating systems including SpartaDOS X,<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> PANOS,<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> and KolibriOS.<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> PowerShell provides <syntaxhighlight lang="text" class="" style="" inline="1">pwd</syntaxhighlight> as an alias for the cmdlet Get-Location
. An equivalent command in COMMAND.COM and Command Prompt is the cd
command with no arguments. On Windows CE 5.0, cmd.exe
includes a pwd
command.<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref> The OpenVMS equivalent is show default
.
The numerical computing environments MATLAB and GNU Octave include a pwd
function with similar functionality.<ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref><ref>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</ref>
The command is implemented as a shell builtin in many Unix shells including sh, ash, bash, ksh, and zsh. It can be implemented with the POSIX getcwd()
or getwd()
functions.
ExamplesEdit
The following examples are based on a typical Unix-based implementation.
With no arguments, the command writes the working directory path to the terminal:
$ cd /home/example $ pwd /home/example
Display the working directory without any symbolic link info. If at a directory /home/symlinked that is a symlink to /home/realdir:
$ cd /home/symlinked $ pwd -P /home/realdir
Display the working directory with symbolic link info. Note: POSIX requires that the default behavior be as if the -L
switch were provided.
$ pwd -L /home/symlinked
Shell variablesEdit
POSIX shells set the following environment variables while using the <syntaxhighlight lang="text" class="" style="" inline="1">cd</syntaxhighlight> command:<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>
- OLDPWD
- The previous working directory
- PWD
- The current working directory
See alsoEdit
- Breadcrumb (navigation), an alternative way of displaying the work directory
- List of POSIX commands
pushd
andpopd
ReferencesEdit
Further readingEdit
External linksEdit
- Template:Man
- Template:Man
- Template:Man
- Template:Man
- Template:Man
- Template:Man
- Template:Man
- Template:Man
Template:Unix commands Template:Plan 9 commands Template:GNU Template:Core Utilities commands