Getting wrong output results in executing the below bash script. The $SPLUNK_DB is missing from the output.
#!/bin/bash
for i in `cat index_name`
do
echo "
[$i]
coldPath = $SPLUNK_DB/$i/colddb
homePath = $SPLUNK_DB/$i/db
thawedPath = $SPLUNK_DB/$i/thaweddb " >> idx_list
echo " "
done
Wrong output results:
[web]
coldPath = /web/colddb
homePath = /web/db
thawedPath = /web/thaweddb
Expecting this output result.
[web]
coldPath = $SPLUNK_DB/web/colddb
homePath = $SPLUNK_DB/web/db
thawedPath = $SPLUNK_DB/web/thaweddb
CodePudding user response:
Escape the $
. Because you are using double quotes, the $ is being interpreted.
#!/bin/bash
for i in `cat index_name`
do
echo "
[$i]
coldPath = \$SPLUNK_DB/$i/colddb
homePath = \$SPLUNK_DB/$i/db
thawedPath = \$SPLUNK_DB/$i/thaweddb " >> idx_list
echo " "
done