PATH environment variable (

Viewed 24

I have a question. When I add to the $PATH variable a directory, dooes the system recognizes as commands only the executables inside that directory or does it also recognizes the executables in subdirectories of that directory and executables in subdirectories of the first subdirectory of the directory.

Thanks in advance!

1 Answers

You can test that yourself

$ mkdir play
$ cd play
$ echo 'echo "I am the outer script"' > outer_script
$ chmod +x outer_script

$ mkdir inner
$ echo 'echo "I am the inner script"' > inner/inner_script
$ chmod +x inner/inner_script

$ export PATH=$(pwd):$PATH
$ cd ~

To see what we did:

$ tree
.
├── inner
│   └── inner_script
└── outer_script

Try running both of them

$ outer_script
I am the outer script
$ inner_script
No such file or directory

So, the answer is no.

Related