pwd

From Wikipedia, the free encyclopedia

Template:Short description Script error: No such module "other uses".

Page Module:Infobox/styles.css has no content.

pwd
[[Programmer|Original authorTemplate:Pluralize from text]]AT&T Bell Laboratories
[[Programmer|DeveloperTemplate:Pluralize from text]]Various open-source and commercial developers
Initial releaseJune 1974; 52 years ago (1974-06)
Template:Infobox software/simple
Written inC
Operating systemMultics, Unix, Unix-like, V, Plan 9, Inferno, SpartaDOS X, PANOS, Windows CE, KolibriOS
PlatformCross-platform
TypeCommand
Licensecoreutils: GPLv3+
Plan 9: MIT License
WebsiteScript error: No such module "WikidataIB".

Script error: No such module "Check for conflicting parameters".

pwd (print working directory)[1][2][3] is a shell command that reports the working directory path to standard output.[4][5][6][7][8][9][10]

Although often associated with Unix, its predecessor Multics had a pwd command (which was a short name of the print_wdir command[11]) from which the Unix command originated.[12] 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.[13] It appeared in Version 5 Unix.[14] The version bundled in GNU Core Utilities was written by Jim Meyering.[15]

The command is available in other shells and operating systems including SpartaDOS X,[16] PANOS,[17] and KolibriOS.[18] PowerShell provides pwd 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.[19] The OpenVMS equivalent is show default.

The numerical computing environments MATLAB and GNU Octave include a pwd function with similar functionality.[20][21]

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.

Examples

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 variables

POSIX shells set the following environment variables while using the cd command:[22]

OLDPWD
The previous working directory
PWD
The current working directory

See also

References

Page Template:Reflist/styles.css has no content.

  1. ^ Page Module:Citation/CS1/styles.css has no content."pwd(1) [minix man page]". www.unix.com.
  2. ^ Page Module:Citation/CS1/styles.css has no content."pwd - print name of current/working directory - man page". www.mankier.com. Archived from the original on 2016-08-28. Retrieved 2016-08-25.
  3. ^ Page Module:Citation/CS1/styles.css has no content."GNU Coreutils". www.gnu.org. Archived from the original on 2004-02-05. Retrieved 2016-07-22.
  4. ^ Page Module:Citation/CS1/styles.css has no content.Unix Time-Sharing System: Unix Programmer's Manual (PDF). Vol. 1 (7th ed.). Bell labs. January 1979. p. 142. Archived from the original (PDF) on 2005-05-20.
  5. ^ Page Module:Citation/CS1/styles.css has no content."pwd(1) [plan9 man page]". www.unix.com.
  6. ^ Page Module:Citation/CS1/styles.css has no content."pwd". pubs.opengroup.org. Archived from the original on 2011-05-16. Retrieved 2020-09-12.
  7. ^ Page Module:Citation/CS1/styles.css has no content."pwd(1) [osf1 man page]". www.unix.com.
  8. ^ Page Module:Citation/CS1/styles.css has no content."Apple OS X MAN page". Archived from the original on 2011-09-24. Retrieved 2015-08-27.
  9. ^ Page Module:Citation/CS1/styles.css has no content."pwd(1) - OpenBSD manual pages". man.openbsd.org. Archived from the original on 2018-02-04. Retrieved 2018-02-04.
  10. ^ Page Module:Citation/CS1/styles.css has no content."pwd(1) [opensolaris man page]". www.unix.com.
  11. ^ Page Module:Citation/CS1/styles.css has no content."working_dir, wd, print_wdir, pwd (Multics help segment)". MIT. Archived from the original on 2 April 2021. Retrieved 7 March 2020.
  12. ^ Page Module:Citation/CS1/styles.css has no content.Van Vleck, Tom. "Unix and Multics". Multicians.org. Archived from the original on 26 April 2022. Retrieved 7 March 2020.
  13. ^ Template:Man
  14. ^ Template:Man
  15. ^ Template:Man
  16. ^ Page Module:Citation/CS1/styles.css has no content."SpartaDOS X 4.48 User Guide" (PDF). Archived (PDF) from the original on 2021-10-10. Retrieved 2019-03-16.
  17. ^ Page Module:Citation/CS1/styles.css has no content."Chris's Acorns: Panos". chrisacorns.computinghistory.org.uk. Archived from the original on 2016-03-31. Retrieved 2019-03-16.
  18. ^ Page Module:Citation/CS1/styles.css has no content."Shell - KolibriOS wiki". wiki.kolibrios.org. Archived from the original on 2019-02-11. Retrieved 2019-03-16.
  19. ^ Page Module:Citation/CS1/styles.css has no content."Command Processor Commands (Windows CE 5.0)". docs.microsoft.com. Archived from the original on 2020-05-15. Retrieved 2020-04-13.
  20. ^ Page Module:Citation/CS1/styles.css has no content."Identify current folder - MATLAB pwd". www.mathworks.com. Archived from the original on 2022-04-09. Retrieved 2019-04-06.
  21. ^ Page Module:Citation/CS1/styles.css has no content."Function Reference: pwd". octave.sourceforge.io. Archived from the original on 2022-04-20. Retrieved 2019-04-06.
  22. ^ Page Module:Citation/CS1/styles.css has no content."cd". pubs.opengroup.org. Archived from the original on 2021-11-09. Retrieved 2020-09-12.

Further reading

Page Module:Side box/styles.css has no content.Page Template:Sister project/styles.css has no content.

Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found. Template:Plan 9 commands Lua error in package.lua at line 80: module 'Module:Navbox/configuration' not found. Template:Core Utilities commands