[oclug] set $PATH
Patrick Smith
patsmith at pobox.com
Thu Jul 10 14:56:15 EDT 2003
Bruce Harding wrote:
> When setting $PATH can I use a wild card?
>
> I.E. export PATH=$PATH:/opt/OpenOffice.org*/program
>
Assuming you are using bash and there are no special characters in the
directory names, you could try this:
export PATH=$PATH:$(ls -d /opt/OpenOffice.org*/program | tr \\12 :)
Note that the expansion happens when you set $PATH, not when you run a
program.
I can't think of any way to get a wildcard directly in the assignment to
work correctly. The problem is that the shell will look for paths
including the PATH=$PATH: part. (One can set IFS=: in order to have the
directories separated by colons instead of spaces in the expansion.)
More information about the OCLUG
mailing list