List=()
cnt=0
while read line
do
if [[ "$line" == "/"* ]]; then
List[$cnt]="$line"
cnt=$((cnt+1))
fi
done < /home/username/settings.conf
echo "start split settings"
for Item in ${List[*]}
do
IFS=',' read -r -a logsets <<< "$Item"
logpath=${logsets[0]}
logname=${logsets[1]}
logtime=${logsets[2]}
...
done
exit 0
cnt=0
while read line
do
if [[ "$line" == "/"* ]]; then
List[$cnt]="$line"
cnt=$((cnt+1))
fi
done < /home/username/settings.conf
echo "start split settings"
for Item in ${List[*]}
do
IFS=',' read -r -a logsets <<< "$Item"
logpath=${logsets[0]}
logname=${logsets[1]}
logtime=${logsets[2]}
...
done
exit 0
本文介绍了一个使用Shell脚本从配置文件中读取并解析设置的例子。通过while循环逐行读取配置文件,并利用if条件判断来存储含有特定格式的数据到数组中。随后通过for循环遍历数组内容,按逗号分隔每一项设置,提取日志路径、名称及时间等信息。
2664

被折叠的 条评论
为什么被折叠?



