这里我得到了 1 个结果,而不是两个应该找到的文件:
mkdir -p mytestdir001
mkdir -p mytestdir002
LIST=`find -maxdepth 1 -name "mytestdir???"`
echo ${#LIST[@]}
最佳答案
使LIST
成为数组而不是变量:
LIST=( `find -maxdepth 1 -name "mytestdir???"` )
同时开始使用 $()
而不是旧的 ``:
LIST=( $(find -maxdepth 1 -name "mytestdir???") )
关于arrays - 如何计算find命令返回的文件数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33274754/