1*43082Scael.\" Copyright (c) 1980, 1990 The Regents of the University of California. 2*43082Scael.\" All rights reserved. 319086Smckusick.\" 4*43082Scael.\" %sccs.include.redist.man% 519086Smckusick.\" 6*43082Scael.\" @(#)cd.1 6.2 (Berkeley) 06/11/90 7*43082Scael.\" 8*43082Scael.Dd 9*43082Scael.Dt CD 1 10*43082Scael.Os BSD 4 11*43082Scael.Sh NAME 12*43082Scael.Nm cd 13*43082Scael.Nd change working directory 14*43082Scael.Sh SYNOPSIS 15*43082Scael.Nm cd 16*43082Scael.Ar directory 17*43082Scael.Sh DESCRIPTION 18*43082ScaelThe cd utility changes the working directory 19*43082Scaelto 20*43082Scael.Ar directory . 21*43082Scael.Pp 22*43082Scael.The 23*43082Scael.Ar directory 24*43082Scaelis an absolute or relative pathname 25*43082Scaelwhich becomes the new working directory. 26*43082ScaelThe 27*43082Scaelinterpretation of a relative pathname by cd depends 28*43082Scaelon the CDPATH environment variable (see below). 29*43082Scael.Pp 30*43082Scael.Sh ENVIRONMENT 31*43082ScaelThe following environment variables affect the execution of 32*43082Scaelcd: 33*43082Scael.Pp 34*43082Scael.Tw Ar 35*43082Scael.Tp Ev HOME 36*43082ScaelIf 37*43082Scael.Nm cd 38*43082Scaelis 39*43082Scaelinvoked without arguments, the 40*43082Scael.Ev HOME 41*43082Scaelenvironment variable is checked for a default 42*43082Scaeldirectory name. If 43*43082Scael.Ev HOME 44*43082Scaelexists and contains 45*43082Scaela directory name, 46*43082Scaelthat directory becomes the new working directory. 47*43082Scael.Tp Ev CDPATH 48*43082ScaelIf the 49*43082Scael.Ar directory 50*43082Scaeloperand does not 51*43082Scaelbegin with a slash (/) character, and the first 52*43082Scaelcomponent is not dot (.) or dot-dot (..), 53*43082Scael.Nm cd 54*43082Scaelsearches for 55*43082Scaelthe directory relative to each directory named in the 56*43082Scael.Ev CDPATH 57*43082Scaelvariable, in the order listed. 58*43082ScaelThe new 59*43082Scaelworking directory is set to the first matching 60*43082Scaeldirectory found. 61*43082ScaelAn empty string in place of a 62*43082Scaeldirectory pathname represents the current directory. 63*43082Scael.Nm Cd 64*43082Scaelwill print the pathname of the new working directory if it 65*43082Scaelwas an element of 66*43082Scael.Ev CDPATH . 67*43082ScaelSee 68*43082Scael.Xr csh 1 69*43082Scaelfor info on environment variables. 70*43082Scael.Tp 71*43082Scael.Pp 72*43082ScaelThe 73*43082Scael.Nm cd 74*43082Scaelutility exits 0 on success, and >0 if an error occurs. 75*43082Scael.Sh SEE ALSO 76*43082Scael.Xr csh 1 , 77*43082Scael.Xr sh 1 , 78*43082Scael.Xr pwd 1 , 79*43082Scael.Xr chdir 2 80*43082Scael.Sh STANDARDS 81*43082ScaelThe 82*43082Scael.Nm cd 83*43082Scaelfunction is expected to be POSIX 1003.2 compatible. 84