I am searching for files by finding a partial file name:
find /script -name '*file_topicv*'
/script/VER_file_topicv_32.2.212.1
It works, but not when the partial file name is a variable:
var=file_topicv
find reported file not found, (in spite of the file existing):
find /script -name '*$var*'
What is wrong here?
I also tried these:
find /script -name "*$var*"
find /script -name "*\$var*"
find /script -name "*\\$var*"
but not one of those works.
Update:
I think this is the problem:
var=` find /tmp -name '*.xml' -exec sed -n 's/<Name>\([^<]*\)<\/Name>/\1/p' {} + | xargs `
echo $var
generateFMN
ls /script/VERSIONS | grep "$var"
NO OUTPUT
var=generateFMN
ls /script/VERSIONS | grep "$var"
VER_generateFMN_32.2.212.1
So why $var from find command cause the problem? (I removed the spaces by xargs.)
bash --version | head -1