Linux – Recursively add directory to $PATH variable


Is it possible to recursively add a directory to my $PATH variable? Let's say I have a directory structure like the following:

    - /nodejs-x.x
    - /redis-x.x
    - /mongodb-x-x

Can I add /usr/local/bin to the $PATH and allow it to recursively cover the subdirectories?

Best Answer

Not directly, no. Entries in $PATH are not recursive.

What you can do is:

for d in /usr/local/bin/*/; do

Another option is to put symlinks in /usr/local/bin:

cd /usr/local/bin
ln -s myapp-1.2/myapp myapp