Help with quotes in find statement in ksh script
Good Afeternoon, I need your help about an script for korn shell.
My idea is to run a find with some -name "*pattern*", and save it's result into a variable and then make a loop with the file names founded.
I'm devoloping for HP-UX.
I've got this variable, filled dinamically and then that I will use to filter my search.
while ...
.
.
.
yearFilter='-name "*'$anioUno'['$mesDec']['$mesUni']*"'
.
.
.
filter="$filtro -o $yearFilter"
done
Then, you can see that the $filter variable conteins:
>echo $filtro
-name "*2010[01][1234567890]*" -o -name "*2011[01][1234567890]*"
But when I use $filter in my find statement:
list=`find . $filter`
echo $list;
The variable $list is empty!
I think that the ksh cant resolv the quotes in the $filter string.
I try using combinations of hard quotes ' and soft quotes " or \" ... but anyone works.
Theres another simplier example, with the same problem:
>filter='-name "*2010[01][1234567890]*" -o -name "*2011[01][1234567890]*"';list=`find . $filter`; echo $list
When I execute this code, its works perfectly:
lista=`find . -name "*2010[01][1234567890]*" -o -name "*2011[01][1234567890]*"`
I really don't know how to solve this problem, I think I have tried with every combination of quotes, but still have no good results.
So if you know how to make it work, please tell me.
Thanks in advance,
Gonzalo
--
Gonzalo Viegas A.
Reply to: