参考stackoverflow的例子,改了一个出来:
while IFS='= ' read var val
do
if [[ $var == \[*] ]]
then
section=$(echo $var | sed 's/^\[\(.*\)\]$/\1/')
elif [[ $val ]]
then
if [ -z $section ];then
declare "${var}=$val"[......]
Shell读取ini文件
Leave a reply