CWD vs PWD

Linux & Unix newsgroup archiveUnix shell2002

Linuxmisc » Unix shell

Shar #1 / 2 Fri, 04 Oct 2002 03:00:00 GMT
What is the difference between "PWD" and "CWD" variables ?

I know that PWD is an environment variable while CWD is normal shell
variable. Is is there any other difference between these ? eg. With
respect to mount options, file system etc.

regards

Ken Pizzi #2 / 2 Fri, 04 Oct 2002 03:00:00 GMT

I presume you mean the "cwd" (lower case) shell variable?  In
which case you must be using a csh-like shell?  According the
the tcsh man page on my sytem:
       PWD (+) Equivalent to the cwd shell variable, but not syn-
               chronized to it;  updated  only  after  an actual
               directory change.
The (+) there indicates that the PWD variable is actually a tcsh
feature not found in traditional csh implementations, so I'll
further guess that you are using tcsh.

What the "not syncronized to it" phrase above refers to is that
the sequence:
    cd /tmp
    echo $cwd $PWD
    set cwd = foo
    echo $cwd $PWD
    cd .
    echo $cwd $PWD
will show different values for the two variables in that middle
echo command.

                --Ken Pizzini

This page is kept from the Linuxmisc archive of Linux and Unix newsgroups (snapshot 2015). Posts are shown as they were published, so commands, versions and addresses date from the original discussion. Linuxmisc.com now publishes a guide to online casinos in Canada.