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.
我有以下代码:
filelist="$(find $name -type f | sort)"; echo "$filelist"; echo "${#filelist[@]}"
我的数组包含许多元素,但最后一个命令说我的数组只包含一个元素。我究竟做错了什么?
您需要使用括号让 bash 将其识别为数组。
filelist=($(find $name -type f | sort)) echo ${#filelist[@]}