Help - Using Find command on dynamic files on KSH

Hi Forum.

When I run the following find command, I get the desired results:

find . \( -name a.out -o -name '*.o' -o -name 'core' \) -type f -ls

I want for my script to dynamically calculate and assign a variable var1 to contain all the files that I want to search instead of hard-coding.

For ex:

var1="-name a.out -o -name '*.o' -o -name 'core'"

but when trying to execute the following command :

find . "\(" "$var1" "\)" -type f -ls

I'm getting the following error:

find: 0652-017 -name a.out -o -name '*.o' -o -name 'core' is not a valid option.

Please help.

Thank you.

Something like this,

var1='-name "a.out" -o -name "*.o" -o -name "core"'
eval find . "\(" $var1 "\)" -type f -ls

sorry - tried your suggestion but got the same error:

find: 0652-017 -name a.out -o -name '*.o' -o -name 'core' is not a valid option.