When I run this with ksh -x testscript, I get the following output.
+ FIND_STRING=\( -name 'testfile*.Z' -o -name 'DUMMY_' \)
+ find /tmp -type f \( -name 'testfile.Z' -o -name 'DUMMY_*' \) -print
find: 0652-009 There is a missing conjunction
If I cut and paste the second line of the output into the dollar prompt, it works fine. Donot know what is happening . I had posted a similar error few weeks before, but now I could pinpoint to a 2 liner.
The variable FIND_STRING is not being expanded by the shell when the find is run and that's why when you replace it with its contents the find command runs alright.
Well, "$FIND_STRING" is being evaluated in that the variable name is being replaced with the variable contents. However, the contents themselves are not being evaluated...that would be double-evaluation, a 15-yard penalty.
You could either use the command 'eval' in front of the 'find' command, or just remove the backslashes when you set the string.
Thanks a lot for your explanation and the eval works fine. I had not used eval before and didn't know it is so vital. I haven't fully digested the solution but will spend some time on it.
pfmurphy, just wondered how did you get the output you had posted with set -x? In my system (ksh on aix) the output is same as I posted in the beginning.