PDA

View Full Version : Add X and all subdirectories of X to PATH?



daviddoria
24th June 2010, 05:49 PM
Is there a way in .bashrc to say, instead of "add X to PATH, add X/Y to PATH, add X/Z to PATH", simply "add all subdirectories of X to PATH"?

Maybe something like



export PATH=$PATH:/home/doriad/X/*


or something like that?

Thanks,
Dave

CChips
24th June 2010, 06:04 PM
Maybe something like?


find . -type d -maxdepth 1 -mindepth 1 >> Export_Location.extension

maxdepth can be set to be logically beyond what exists...for example...100?

*I added >> because I for some reason assumed you want the data to go somewhere.

daviddoria
24th June 2010, 06:09 PM
That is a good idea. It may take some cleverness to separate those directories that are found with colons!

It would be nice to something like


export PATH=$PATH:`find . -type d -maxdepth 1100 -mindepth 1`


But I believe it's going to be much more complicated than that, right?

Dave

droidhacker
24th June 2010, 07:12 PM
That is a good idea. It may take some cleverness to separate those directories that are found with colons!

It would be nice to something like


export PATH=$PATH:`find . -type d -maxdepth 1100 -mindepth 1`


But I believe it's going to be much more complicated than that, right?

Dave

Nope, no cleverness at all.....

for FILE in `find .........`; do
PATH=$PATH:$FILE
done
export $PATH


BTW: what are you trying to accomplish? A big ugly messy path that takes forever to process and runs weird and unpredictable commands?

daviddoria
24th June 2010, 07:20 PM
Ah cool, thanks.

I have a directory of small c++ programs that I want to be able to run from anywhere.

/home/doriad/Projects/project1/bin/
/home/doriad/Projects/project2/bin/
/home/doriad/Projects/project3/bin/

etc.

I suppose I could change all of their build directories to a common location - if I notice any problems with the big PATH that you are predicting I'll have to do that.

Thanks for your help.

Dave