Click to See Complete Forum and Search --> : Wildcards allowed in $PATH?


foppa
01-05-2001, 11:00 PM
I'm getting the hang of compiling and installing software from source. So far, everything is going into /usr/local/foo - because I don't know any better, and it's easy to delete and try again when something goes wrong.

After getting tired of having to type /usr/local/foo/bin/program to run a program, I tried to find information on adding things to my $PATH. The method I'm using right now is taken from the compiling software NHF, in which you add 2 lines to the bottom of /etc/profile for each program.

This seems very cumbersome. Is there a more elegant & efficient way? Since most programs seem to go into /usr/local/program, is it possible to use a wildcard in your $PATH? Something like /usr/local/*/bin? Would that work for /usr/local/foo/bin as well as /usr/local/bar/bin?

Is there a man page or how-to for this issue? I couldn't find anything, but I'm sure it's only because I wasn't looking in the right place.

Thanks

Strike
01-05-2001, 11:22 PM
I generally just put symlinks to the program executable in /usr/bin, which is already in my path. Though I think you could do some sort of bash scripting like


MY_DIR_FILE=/etc/my.conf
ls -l /usr/local | grep ^d | awk '{print $9}' > $MY_DIR_FILE
for dir in --somehow list the file contents--; do
PATH=$PATH:/usr/local/$dir/bin
done


Maybe that file redirection is unnecessary.. lemme see if I can fix that.

Strike
01-05-2001, 11:23 PM
It was unnecessary, here's your script:


#!/bin/bash

for dir in `ls -l /usr/local | grep ^d | awk '{print $9}'`; do
PATH=$PATH:/usr/local/$dir/bin
done

export PATH


Or just copy that for loop into /etc/profile or wherever.

[This message has been edited by Strike (edited 05 January 2001).]

foppa
01-05-2001, 11:39 PM
Thanks! I think this is exactly what I'm looking for.