xref: /freebsd/bin/pwd/pwd.1 (revision 1719886f6d08408b834d270c59ffcfd821c8f63a)
1.\"-
2.\" Copyright (c) 1990, 1993
3.\"	The Regents of the University of California.  All rights reserved.
4.\"
5.\" This code is derived from software contributed to Berkeley by
6.\" the Institute of Electrical and Electronics Engineers, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.Dd May 22, 2023
33.Dt PWD 1
34.Os
35.Sh NAME
36.Nm pwd
37.Nd return working directory name
38.Sh SYNOPSIS
39.Nm
40.Op Fl L | P
41.Sh DESCRIPTION
42The
43.Nm
44utility writes the absolute pathname of the current working directory to
45the standard output.
46.Pp
47Some shells may provide a builtin
48.Nm
49command which is similar or identical to this utility.
50Consult the
51.Xr builtin 1
52manual page.
53.Pp
54The options are as follows:
55.Bl -tag -width indent
56.It Fl L
57Display the logical current working directory.
58.It Fl P
59Display the physical current working directory (all symbolic links resolved).
60.El
61.Pp
62If no options are specified, the
63.Fl P
64option is assumed.
65.Sh ENVIRONMENT
66Environment variables used by
67.Nm :
68.Bl -tag -width ".Ev PWD"
69.It Ev PWD
70Logical current working directory.
71.El
72.Sh EXIT STATUS
73.Ex -std
74.Sh EXAMPLES
75Show current working directory with symbolic links resolved:
76.Bd -literal -offset indent
77$ /bin/pwd
78/usr/src/sys/kern
79.Ed
80.Pp
81Show the logical current directory.
82Then use
83.Xr file 1
84to inspect the
85.Pa /sys
86directory:
87.Bd -literal -offset indent
88$ /bin/pwd -L
89/sys/kern
90$ file /sys
91/sys: symbolic link to usr/src/sys
92.Ed
93.Sh SEE ALSO
94.Xr builtin 1 ,
95.Xr cd 1 ,
96.Xr csh 1 ,
97.Xr realpath 1 ,
98.Xr sh 1 ,
99.Xr getcwd 3
100.Sh STANDARDS
101The
102.Nm
103utility conforms to
104.St -p1003.1-2001 .
105.Sh HISTORY
106The
107.Nm
108command appeared in
109.At v5 .
110.Sh BUGS
111In
112.Xr csh 1
113the command
114.Ic dirs
115is always faster because it is built into that shell.
116However, it can give a different answer in the rare case
117that the current directory or a containing directory was moved after
118the shell descended into it.
119.Pp
120The
121.Fl L
122option does not work unless the
123.Ev PWD
124environment variable is exported by the shell.
125