我对我的脚本运行了 shellcheck
, 发现一个非常简单的错误 -
echo "删除的字段列表:${deleted[@]}"
^-----------^ SC2145: 参数混合了字符串和数组。使用*或分开参数。
我尝试实现以下类似的行为 -
declare -a deleted
deleted = ("some.id.1" "some.id.22" "some.id.333")
echo "List of fields deleted: ${deleted[@]}"
哪种打印数组元素的方式更好?
echo "List of fields deleted: ${deleted[@]}"
或者
echo "List of fields deleted: "
for deletedField in "${deleted[@]}"; do echo "${deletedField}"; done