分页: 1 / 1

不明白什么意思 done < <(find $path -type f -print)

发表于 : 2015-12-30 18:27
best1196
bash code :
if [ $# -ne 1 ];
then
echo “Usage is $0 basepath”;
exit
fi
path=$1

declare -A statarray;

while read line;
do
ftype=`file -b "$line" | cut -d, -f1`
let statarray["$ftype"]++;

done < <(find $path -type f -print)

echo ============ File types and counts =============
for ftype in "${!statarray[@]}";
do
echo $ftype : ${statarray["$ftype"]}
done

这段代码是linux脚本攻略里面的,看到 done < <(find $path -type f -print) 时看不懂了,done 后面接<< ,

Re: 不明白什么意思 done < <(find $path -type f -print)

发表于 : 2015-12-30 19:07
susbarbatus
不是 done 后面接 << , 这两个 < 是分开的,
第一个 < 是输入重定向,后面的 <(...) 是一起的,是 Process Substitution,
这两个组合在一起的效果类似管道,就是把<()里的执行结果作为输入传给前面的循环。