143082Scael.\" Copyright (c) 1980, 1990 The Regents of the University of California. 243082Scael.\" All rights reserved. 319086Smckusick.\" 443082Scael.\" %sccs.include.redist.man% 519086Smckusick.\" 6*44952Scael.\" @(#)cd.1 6.3 (Berkeley) 07/24/90 743082Scael.\" 843082Scael.Dd 943082Scael.Dt CD 1 1043082Scael.Os BSD 4 1143082Scael.Sh NAME 1243082Scael.Nm cd 1343082Scael.Nd change working directory 1443082Scael.Sh SYNOPSIS 1543082Scael.Nm cd 1643082Scael.Ar directory 1743082Scael.Sh DESCRIPTION 1843082ScaelThe cd utility changes the working directory 1943082Scaelto 2043082Scael.Ar directory . 2143082Scael.Pp 22*44952ScaelThe 2343082Scael.Ar directory 2443082Scaelis an absolute or relative pathname 2543082Scaelwhich becomes the new working directory. 2643082ScaelThe 2743082Scaelinterpretation of a relative pathname by cd depends 2843082Scaelon the CDPATH environment variable (see below). 2943082Scael.Pp 3043082Scael.Sh ENVIRONMENT 3143082ScaelThe following environment variables affect the execution of 3243082Scaelcd: 3343082Scael.Pp 34*44952Scael.Tw Fl 3543082Scael.Tp Ev HOME 3643082ScaelIf 3743082Scael.Nm cd 3843082Scaelis 3943082Scaelinvoked without arguments, the 4043082Scael.Ev HOME 4143082Scaelenvironment variable is checked for a default 4243082Scaeldirectory name. If 4343082Scael.Ev HOME 4443082Scaelexists and contains 4543082Scaela directory name, 4643082Scaelthat directory becomes the new working directory. 4743082Scael.Tp Ev CDPATH 4843082ScaelIf the 4943082Scael.Ar directory 5043082Scaeloperand does not 5143082Scaelbegin with a slash (/) character, and the first 5243082Scaelcomponent is not dot (.) or dot-dot (..), 5343082Scael.Nm cd 5443082Scaelsearches for 5543082Scaelthe directory relative to each directory named in the 5643082Scael.Ev CDPATH 5743082Scaelvariable, in the order listed. 5843082ScaelThe new 5943082Scaelworking directory is set to the first matching 6043082Scaeldirectory found. 6143082ScaelAn empty string in place of a 6243082Scaeldirectory pathname represents the current directory. 6343082Scael.Nm Cd 6443082Scaelwill print the pathname of the new working directory if it 6543082Scaelwas an element of 6643082Scael.Ev CDPATH . 6743082ScaelSee 6843082Scael.Xr csh 1 6943082Scaelfor info on environment variables. 7043082Scael.Tp 7143082Scael.Pp 7243082ScaelThe 7343082Scael.Nm cd 7443082Scaelutility exits 0 on success, and >0 if an error occurs. 7543082Scael.Sh SEE ALSO 7643082Scael.Xr csh 1 , 7743082Scael.Xr sh 1 , 7843082Scael.Xr pwd 1 , 7943082Scael.Xr chdir 2 8043082Scael.Sh STANDARDS 8143082ScaelThe 8243082Scael.Nm cd 8343082Scaelfunction is expected to be POSIX 1003.2 compatible. 84