Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的代码
TOTAL=${#FOO_5[*]} // COUNT ITEMS IN ARRAY
如果代码怎么办
ARRAY_NAME="FOO_5" TOTAL=${#${!ARRAY_NAME}[*]} //error
请修复
当涉及到间接参数扩展时,数组索引被认为是参数名称的一部分。不幸的是,您不能链接参数扩展;您还需要一个中间变量。
ARRAY_NAME="FOO_5[*]" FULL=${!ARRAY_NAME} TOTAL=${#FULL}