I have a file configure.sh with following (it creates a test.sh file with configuration, so that i can use that test.sh finally as main configuration task). But it does not work
cat > /var/tmp/test.sh << EOF
regex='value=(.*)'
for i in $(cat /var/tmp/test.ini);
do
if [[ $i =~ $regex ]];
then
echo ${BASH_REMATCH[1]}
#or
curl -v ${BASH_REMATCH[1]}
fi
done
EOF
When the configure.sh is executed it makes the test.sh file completely wrong such as reged='value(.*)'
for i in
original line1
original line1
original line1
original line1
do
if [[ =~ ]];
then
fi
done
EOF
The EOF block is not writing exactly how i set above. How do you write such string inside EOF?
From
man bash
, section Here Documents:So write
<< \EOF
instead of<< EOF
.