On my office computer it seems like I've have two PATH
variables.
$path : This is delimited by " " (Space)
$PATH : This is delimited by ":" (Colon)
Though when I update one, the other one gets updated as well. Is this the normal behavior in Linux or is there something weird going on in my machine?
Should I keep them both, or delete one of them?
Edit: I'm using csh
, I found this because some of my colleagues were updating the "path" variable, while others did it with PATH
. Though I deleted all occurrences of updating PATH
in my .cshrc
, it still appears when I try to echo them.
Best Answer
The real
PATH
variable is the uppercase one, except in (t)csh itself where it's a little more complicated.PATH
is an environment variable, which all applications (not just shell) look up to invoke a program by name. The value ofPATH
is a string listing directory names separated by colons.As a convenience, csh also provides a variable called
path
. The value of this variable is a list of strings, each string being a directory name. Whenever you setpath
, csh automatically setsPATH
to the concatenation of the elements ofpath
with:
between elements.If you set
PATH
withset
,path
is unaffected. Furthermore, csh set thePATH
environment variable to match itspath
internal variable, soset PATH=...
has no practical effect.If you set
PATH
withsetenv
,path
is updated accordingly. Howeversetenv PATH …
does not affect what$PATH
expands to, which makes it awkward to use.The upshot is that in csh, you should stick with
path
. But everywhere elsePATH
is the only one you'll see.