1
在第二次插入关联数组'originator'的代码中,使第一次插入丢失。我检查第一个插入是成功的,但是当我将第二个关联项放入'originators'时,第一个项是空的,换句话说,它输出并为空字符串。我不知道会发生什么事。第二次插入到关联数组中的数据丢失
declare -A originators
while read -r line
do
if [ "$count" -ge "2" ];
then
inner_count=0
#parse each line
if [ "$debug" = "1" ] ; then printf "%s\n" "$line" ; fi
for word in $line
do
if [ "$inner_count" = "1" ]; then tmp1="$word" ; fi
if [ "$inner_count" = "5" ]; then tmp1="$tmp1"" ---- ""$word" ;fi
inner_count=$((inner_count + 1))
done
originators=(["$count"]="$tmp1")
echo "$count ${originators["$count"]}"
fi
count=$((count + 1))
done < <(batctl tg)
非常感谢您的解决方案。 – user1658296
不客气,很高兴它解决了。 – anubhava