There are three main files test.cnf test.sh test.txt
Execute test.sh to read the configuration of test.cnf to modify the content of test.txt. During the execution, the configuration is read successfully but sed is executed. The time was not found.
sed is just debugging here without modifying test.txt, it just displays the results of test.txt
[root@localhost /tmp]# head -100 test* ==> test.cnf <== yy=123 ppp=456 ==> test.sh <== function myconf(){ source test.cnf awk -F'=' '{print }' test.cnf|while read myline;do sed s/{{$myline}}/${$myline}/g test.txt;done } myconf ==> test.txt <== uuu={{yy}} ooo={{ppp}}
Execution errors are displayed during debugging;
[root@localhost /tmp]# bash -x test.sh + myconf + source test.cnf ++ yy=123 ++ ppp=456 + read myline + awk -F= '{print }' test.cnf test.sh: line 4: s/{{$myline}}/${$myline}/g: bad substitution
Other methods: