[-1c?
@(#)$Id: cd (AT&T Research) 2013-08-18 $
]
[+NAME?cd - change working directory ]
[+DESCRIPTION?\bcd\b changes the current working directory of the current shell environment.]
[+?In the first form with one operand, if \adirectory\a begins with \b/\b, or if the first component is \b.\b or \b..\b, the directory will be changed to this directory.  If directory is \b-\b, the directory will be changed to the last directory visited.  Otherwise, if the \bCDPATH\b environment variable is set, \bcd\b searches for \adirectory\a relative to each directory named in the colon separated list of directories defined by \bCDPATH\b.  If \bCDPATH\b not set, \bcd\b changes to the directory specified by \adirectory\a.]
[+?In the second form, the first occurrence of the string \aold\a contained in the pathname of the present working directory is replaced by the string \anew\a and the resulting string is used as the directory to which to change.]
[+?When invoked without operands and when the \bHOME\b environment variable is set to a nonempty value,  the directory named by the \bHOME\b environment variable will be used.  If \bHOME\b is empty or unset, it will use the home directory for the effective user if possible.  Otherwise \bcd\b will fail.]
[+?When \bcd\b is successful, the \bPWD\b environment variable will be set to the name of an absolute pathname that does not contain any \b..\b components corresponding to the new directory.  The environment variable \bOLDPWD\b will be set to the previous value of \bPWD\b.  If the new directory is found by searching the directories named by \bCDPATH\b, or if \adirectory\a is \b-\b, or if the two operand form is used, the new value of \bPWD\b will be written to standard output.]
[+?If both \b-L\b and \b-P\b are specified, the last one specified will be used.  If neither \b-P\b or \b-L\b is specified the default behavior is as if \b-L\b was specified.]
[f?The directory path is relative to the open file descriptor \adirfd\a.]#[dirfd]
[L?Handle each pathname component \b..\b in a logical fashion by moving up one level by name in the present working directory.]
[P?The present working directory is first converted to an absolute pathname that does not contain symbolic link components and symbolic name components are expanded in the resulting directory name.]
[@?Change into the hidden attribute directory of \adirectory\a which may also be a file. \bCDPATH\b is ignored. Hidden attribute directories are file system and operating system specific.]

[directory]
old new

[+EXIT STATUS?]{
[+0?Directory successfully changed.]
[+>0?An error occurred.]
}
[+SEE ALSO?\bpwd\b(1)]
