Problem: expand value of variables. You try it, but not to do it.
Understanding difference between ' and " in the command line.
VAR=string
echo 'Variable value is $VAR and ...'
# echo
# Variable value is $VAR and ...
# not
# Variable value is string and ...
# but this work, expand value of
echo "Variable value is $VAR and ..."
If you have " in your constant string, then you need remove special meaning of " to the char ".
Method1:
echo 'Variable value is '$VAR' and ...'
# or
echo "Variable value is $VAR and .."
# if you need echo ", then take of " special meaning
echo "Variable value is \"$VAR\" and .."
In your case I like to use HERE template. It's so nice to make dynamic templates. End TAG have to be col 1 in the line.
Methdod2:
# in this example used with cat. HERE is redirect from stdin, usable with any commands which support stdin.
cat <<TAG
Variable value is "$VAR" and ...
Today is $(date)
<Element>$VAR</Element>
<Child attr="$VAR2">Some</Child>
TAG
echo "So nice"
TAG you can define as you like it: EOT, EOF, XML, HTML, TEMPLATE, ...
Why you cat file to the variable? Why not just:
done < "C:/opti/O0904/cnhbensonol1/out.txt"
Or why first to the variable and then to file, why not directly cmd stdout redirect to the file?
cygpath -w "C:/opti/O0904/cnhbensonol1/parts2do/"*.* > tmp
And then just
while read line
do
...
done < tmp