[comp.unix.questions] How do you use CDPATH?

jscott@isis.cs.du.edu (James Scott) (05/03/91)

How do you use the environment variable CDPATH? I'm using
both ATT SysV.3's sh and ntcsh version 5.12.
Thanx,
		James

--
=========================================================================
James Scott                                       scott@gwhs.colorado.edu 
                                                    jscott@isis.cs.du.edu
George Washington H.S., Denver				     gwhs@csn.org

toma@swsrv1.cirr.com (Tom Armistead) (05/03/91)

In article <1991May2.203153.13842@mnemosyne.cs.du.edu> jscott@isis.cs.du.edu (James Scott) writes:
>How do you use the environment variable CDPATH? I'm using
>both ATT SysV.3's sh and ntcsh version 5.12.
>Thanx,
>		James
>
>--
>=========================================================================
>James Scott                                       scott@gwhs.colorado.edu 
>                                                    jscott@isis.cs.du.edu
>George Washington H.S., Denver				     gwhs@csn.org

The CDPATH env var is used by the shell cd command.  cd will search for the
named directory along the path specified by CDPATH and if it finds it, will
change to it.  This allows you to change to directories without specifying
the full path.
  Ex.
    $ CDPATH=$HOME:/usr:/usr/local;export CDPATH
    $ mkdir $HOME/testing
    $ cd /
    $ cd testing

Tom
-- 
Tom Armistead - Software Services - 2918 Dukeswood Dr. - Garland, Tx  75040
===========================================================================
toma@swsrv1.cirr.com                {egsner,letni,ozdaltx,void}!swsrv1!toma

urban@cbnewsl.att.com (john.urban) (05/04/91)

In article <1991May2.203153.13842@mnemosyne.cs.du.edu> jscott@isis.cs.du.edu (James Scott) writes:
>How do you use the environment variable CDPATH? I'm using
>both ATT SysV.3's sh and ntcsh version 5.12.
>Thanx,
>		James
>


Under the Bourne shell here's a little example .....

$ CDPATH=:/:/usr	# <-Just like PATH, look in . first, then / then /usr
$ export CDPATH
$ cd /usr		
$ cd bin		# <- finds bin under . so go there.
$ pwd
/usr/bin
$ cd bin		# <- does not find bin under . so now search for first
			#    bin directory un the $CDPATH variable.
/bin			# <- automatically prints out where it found it.
$ pwd
/bin

Sincerely,

John Urban
att!garage!jbu