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" else declare "${section}.${var}=$val" fi fi done < config.ini
使用的时候:
转载请注明:爱开源 » Shell读取ini文件