2

As seen here, doing echo $PATH gives me my full PATH, but doing simply $PATH gives an incomplete version that looks like it hasn't been escaped properly somewhere:

enter image description here

Yet when I look into my configuration files, the only relevant lines for the PATH seem to be:

PATH=$PATH

...in .bashrc, and...

export PATH=usr/local/sbin:/usr/sbin:$PATH
export PATH=/sbin:$PATH
export PATH=/cygdrive/b/users/me/desktop:$PATH

...in .bash_profile. Both seem correctly formatted to me, so I'm unsure what's going on here. Can anyone else shed some light on it?

1
  • 1
    Generally, the first thing on the command line should be a command name (well, or an assignment). $PATH is a variable... that doesn't contain a valid command name. So running $PATH as a command is not really expected to do anything particularly sane. Sep 8, 2018 at 1:06

2 Answers 2

3

(I assume you deleted your username from between users/ and /desktop. It now looks like few spaces, but in fact there is no space there.)

When you invoke sole $PATH, the first space in it separates what bash interprets as a command from its first argument. No such file or directory refers to the "command".

The first space is in Program Files, therefore the "command" ends with Program. It fails because there's no such file.

2

PATH is a variable (that is used by the shell to try and locate programs by looking in each of it's directories.)

When you run echo $PATH you are showing the contents if it.

When you run $PATH you are attempting to run the command included in the variable. As this is a list of directories, it's not a valid command do it produces the error.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .