"Robert Anderson" <RWA@sbcglobal.net> wrote:
> prune_dirs="{arch}"
> prune=
> for dir in $prune_dirs; do
> prune="$prune -path *${dir}* -prune -o"
> done
> files=`find "$arch_src" $prune -name \*.sh -print &> /dev/null`
man bash, EXPANSION:
The order of expansions is: brace expansion, tilde expan
sion, parameter, variable and arithmetic expansion and
command substitution (done in a left-to-right fashion),
word splitting, and pathname expansion.
So $prune is substituted in the find command, and then the resulting
*{arch}* wildcard is expanded, instead of being passed verbatim to
find. Try this instead:
shift "$#" # or, if you want to be more portable: set -- x; shift
prune_dirs='{arch}'
for dir in $prune_dirs; do
set -- ${1+"$@"} -path "*$dir*" -prune -o
done
files=`find "$arch_src" ${1+"$@"} -name \*.sh -print`
Side note: I think you actually want "*/$dir" instead of "*$dir*".
paul