Q:

How to find paths matches a sub-string in a root directory recursively?

I want to find file paths that matches a specific sub-string in a specific root directory.
Below is my shell script. When I test one by one, the results are good. But when I loop, the result is empty. Who can give advice on the cause?
my script
filename=include_pattern
cat $filename | while read LINE
do
    echo $LINE
    path=$(echo $LINE |cut -d'(' -f2|cut -d')' -f1)
    echo $path
    result=$(find . -path $path)
    echo $result
done

include_pattern 
file('.*/cm-audio/src/main/*')
file('.*/cm-common/include/cm_common/utils/*')

I extract only the contents of file () by
path=$(echo $LINE |cut -d'(' -f2|cut -d')' -f1)

Now, I try to find paths including sub-string $path by
find . -path $path

The result is empty.
However, if I try it by standalone in command line, it returns path lists. for example,
find . -path '.*/cm-audio/src/main*'

I cannot the reason why this full script doesn't work.
Could you let me some advice about this?

A:

Try this:
filename='text_file_containing_include_pattern_on_each_line.txt'
while IFS='' read -r line || [[ -n "$line" ]]; do
    path=$(echo "$line" |cut -d'(' -f2|cut -d')' -f1)
    find \. -path "${path//\'}"
done < $filename

Ah wait.. I thought you where reading from a textfile that contained lines like:
file('.*/cm-audio/src/main/*')
file('.*/cm-common/include/cm_common/utils/*')

But I see now I was mistaken.. let me adapt my answer in a sec..
EDIT
In case you stored your include_pattern in a variable:
include_pattern="file('.*/cm-audio/src/main/*')
file('.*/cm-common/include/cm_common/utils/*')"
for file in $include_pattern; do
    path=$(echo "$file" |cut -d'(' -f2|cut -d')' -f1)
    find \. -path "${path//\'}"
done

