Kirk, Try something like the following - this works for me. The set -x provides a "trace" and should be removed for actual use.
#!/bin/sh set -x paths_to_exclude='/tmp/dir1/Program Files /tmp/fileobJEbT-rep-tarfh /tmp/orbit* /tmp/quickenw' call=`echo "$paths_to_exclude" | ( stuff= while read line do stuff="$stuff -path '$line' -prune -o" done echo $stuff)` call="find /tmp/ $call" call="$call -print" echo "Calling..." echo $call eval $call Lynne kirk wrote: > I am trying to get a list of /mnt/dosc excluding "Program Files" and > "quickenw" from within this script. This is a stripped down version of > what would normally include variables, but it illustrates the concept. > > Here is the script: > > #!/bin/sh > paths_to_exclude="/mnt/dosc/Program?Files /mnt/dosc/quickenw" > call="find /mnt/dosc/" > > for i in $paths_to_exclude ; do > call="$call -path '"$i"' -prune -o" > done > > call="$call -print" > echo "Calling..." > echo $call > $call > > [end script] > > Running this script generates the following: > > Calling... > find /mnt/dosc/ -path '/mnt/dosc/Program Files' -prune -o -path > '/mnt/dosc/quickenw' -prune -o -print > find: paths must precede expression > Usage: find [path...] [expression] > > However, running the command > find /mnt/dosc/ -path '/mnt/dosc/Program Files' -prune -o -path > '/mnt/dosc/quickenw' -prune -o -print > > Generates the desired output. > > I assume part of the problem is the "?", but I have to keep the string > together or the for loop breaks it up. Is there any other way to get > this thing to go thru the for loop intact? Also, why does running the > same command as $call work from the command prompt? > > Any help would be appreciated. > > Kirk > > _______________________________________________ > Redhat-list mailing list > [EMAIL PROTECTED] > https://listman.redhat.com/mailman/listinfo/redhat-list _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list