我有一个循环变量名称,我需要检查该名称指向的变量是否是一个数组。我试图google,但什么也找不到。任何帮助?
for varname in AA BB CC; do local val if [ "$varname" is array ]; then # how can I perform this test? echo do something with an array else echo do something with a "'normal'" variable fi done
Google可能是
your friend:
declare -p variable-name 2> /dev/null | grep -q '^declare \-a'