Pwd

pwd
The pwd command
The pwd command
原作者贝尔实验室
開發者多个开源软件商业软件开发者
首次发布1974年6月,​50年前​(1974-06
操作系统Multics, Unix, Unix-like, V, Plan 9, Inferno, SpartaDOS X, PANOS, Windows CE, KolibriOS
平台跨平台
类型命令
许可协议coreutils: GPLv3

类Unix系统和其他一些操作系统中,pwd(英語:print working directory[1][2][3]用于将当前工作目录的完整路径输出到标准输出[4][5][6][7][8][9][10]

实现

Multics有一个 pwd 命令(是 print_wdir 命令的短名称)[11],Unix的pwd命令由此起源。[12]在大部分Unix shell,如Bourne shellash、bash、kshzsh中,它是内建命令 ,可以用POSIX C函数 getcwd()getwd() 轻易实现。

它还在SpartaDOS X[13]、PANOS[14]KolibriOS[15]上可用。DOSCOMMAND.COM)和Microsoft Windowscmd.exe)中与之等价的是没有参数的cd命令。Windows PowerShell还提供对等的Get-Location cmdlet,以及标准的别称glpwd。在 Windows CE 5.0上,cmd.exe (Command Processor Shell)包含了pwd命令。[16]

自1987年的第二版起,Unix上的pwd就是X/Open可移植手册的一部分。它已被继承到POSIX.1第一版和单一UNIX规范中。[17]它还在Unix第五版中出现过。[18] GNU核心工具组打包的pwd版本由Jim Meyering编写。[19]

Windows PowerShell提供等价的“Get-Location”cmdlet并有标准别名“gl”和“pwd”。

数值分析环境MATLABGNU Octave包含一个 pwd 函数,行使类似的功能。[20][21]OpenVMS中则与show default等价。

*nix上的示例

Command 解释
pwd 显示当前工作目录。例如:/home/foobar
pwd -P 显示当前工作目录的物理路径,若有任何符号链接名称则不显示。例如:在目录/home/symlinked下有一个指向/home/realdir的符号链接,则显示/home/realdir
pwd -L 显示当前工作目录的物理路径,且显示任何符号链接名称。例如:在目录/home/symlinked下有一个指向/home/realdir的符号链接,则显示/home/symlinked

注意:POSIX要求默认行为和提供 -L 开关时的行为相同。

工作目录环境变量

在使用cd命令时,POSIX壳层会设置下列环境变量[22]

OLDPWD
上一个工作目录(由cd命令设置)。
PWD
当前工作目录(由cd命令设置)。

参见

参考

文件系統
  • cat
  • cd
  • chmod
  • chown
  • chgrp
  • cksum
  • cmp
  • cp
  • dd
  • du
  • df
  • file
  • fsck
  • fuser
  • ln
  • ls
  • mkdir
  • mount
  • mv
  • pax英语pax (Unix)
  • pwd
  • rm
  • rmdir
  • size
  • split
  • stat
  • tee
  • touch
  • type英语type (Unix)
  • umask英语umask
程序
  • at
  • bg
  • chroot
  • cron
  • fg
  • kill
  • killall英语killall
  • nice
  • pgrep
  • pkill英语pkill
  • ps
  • pstree英语pstree
  • time
  • top
用户环境
  • clear
  • env
  • exit
  • history英语history (Unix)
  • id
  • logname
  • mesg英语mesg
  • passwd
  • su
  • sudo
  • uptime
  • talk英语talk (software)
  • tput英语tput
  • uname
  • w
  • wall英语wall (Unix)
  • who
  • whoami
  • write英语write (Unix)
文本编辑
  • awk
  • banner英语banner (Unix)
  • basename
  • comm英语comm
  • csplit英语csplit
  • cut
  • diff
  • dirname
  • ed
  • ex
  • fmt英语fmt
  • fold英语fold (Unix)
  • head英语head (Unix)
  • iconv
  • join英语join (Unix)
  • less
  • more
  • nl英语nl (Unix)
  • paste英语paste (Unix)
  • sed
  • sort英语sort (Unix)
  • spell英语spell (Unix)
  • strings英语strings (Unix)
  • tail
  • tr
  • uniq英语uniq
  • vi
  • wc
  • xargs
壳层内建
网络
查找
文档
  • apropos英语apropos (Unix)
  • help英语help (command)
  • man
软件开发
杂项
  • bc
  • cal
  • dc
  • expr
  • lp英语lp (Unix)
  • lpr
  • sleep
  • true和false
  • yes
  1. ^ pwd(1) [minix man page]. www.unix.com. 
  2. ^ pwd - print name of current/working directory - man page. www.mankier.com. [2021-10-02]. (原始内容存档于2016-08-28). 
  3. ^ GNU Coreutils. www.gnu.org. [2021-10-02]. (原始内容存档于2020-12-04). 
  4. ^ Unix Time-Sharing System: Unix Programmer's Manual (PDF) 1 7th. Bell labs. January 1979: 142. (原始内容 (PDF)存档于2005-05-20). 
  5. ^ pwd(1) [plan9 man page]. www.unix.com. 
  6. ^ pwd. pubs.opengroup.org. [2021-10-02]. (原始内容存档于2011-05-16). 
  7. ^ pwd(1) [osf1 man page]. www.unix.com. 
  8. ^ Apple OS X MAN page. [2021-10-02]. (原始内容存档于2011-09-24). 
  9. ^ pwd(1) - OpenBSD manual pages. man.openbsd.org. [2021-10-02]. (原始内容存档于2018-02-04). 
  10. ^ pwd(1) [opensolaris man page]. www.unix.com. 
  11. ^ working_dir, wd, print_wdir, pwd (Multics help segment). MIT. [7 March 2020]. (原始内容存档于2021-04-02). 
  12. ^ Van Vleck, Tom. Unix and Multics. Multicians.org. [7 March 2020]. (原始内容存档于2022-04-26). 
  13. ^ SpartaDOS X 4.48 User Guide (PDF). [2021-10-10]. (原始内容 (PDF)存档于2021-10-10). 
  14. ^ Chris's Acorns: Panos. chrisacorns.computinghistory.org.uk. [2021-10-10]. (原始内容存档于2016-03-31). 
  15. ^ Shell - KolibriOS wiki. wiki.kolibrios.org. [2021-10-10]. (原始内容存档于2019-02-11). 
  16. ^ Command Processor Commands (Windows CE 5.0). docs.microsoft.com. [2021-10-10]. (原始内容存档于2020-05-15). 
  17. ^ wc – 命令与工具(Commands & Utilities)参考,单一UNIX®规范第7期,由國際開放標準組織发布
  18. ^ pwd(1) – FreeBSD通用命令(General Commands)手册页
  19. ^ pwd(1) – Linux程序员手册页 – 用户命令(User Commands)
  20. ^ Identify current folder - MATLAB pwd. www.mathworks.com. [2021-10-02]. (原始内容存档于2022-04-09). 
  21. ^ Function Reference: pwd. octave.sourceforge.io. [2021-10-02]. (原始内容存档于2022-04-20). 
  22. ^ cd. pubs.opengroup.org. [2021-10-02]. (原始内容存档于2021-11-09).