【发布时间】:2018-02-24 17:46:25
【问题描述】:
在 bash 脚本中,我在变量中有一个语言环境,像这样
locale=fr_ma
我也有这样的关联数组
declare -A new_loc_map
new_loc[fr_ma]=en_ma
new_loc[el_gr]=en_gr
new_loc[sl_si]=en_si
我想检查带有${locale} 键的new_loc 元素是否存在
我认为这应该可行,但它没有:
if [[ -v "${new_loc[${locale}]}" ]]
then
echo -e "${locale} has a new_loc"
fi
fi
关于我可以如何测试的任何想法?
【问题讨论】:
标签: arrays bash associative-array