Sourcing a Directory

Morten W. J. morten at newtec.dk
Mon Jun 13 11:17:34 UTC 2005


> > How do I "source" a directory?
>
> for file in ~/.bash_profile_pieces/*; do source $file; done

That will work for directories with few files, but eventually your ./xyz/abc/* 
URL might expand to more arguments than you shell can handle. That will break 
the script.

A more general approach would be to do line this:

for file in `find /xyz/abc/ -maxdepth 1`; do source $file; done

as it will not be limited by your shells ability to expand more than x matches 
from *

-- 
Morten W. Jørgensen




More information about the ubuntu-users mailing list