0
我有这样的结构::排序-n一个bash空间的内容分割的项目阵列
.
├── b withe spaces.py
├── c.py
├── lib.py
├── show.sh
└── sub
└── a.py
我想这个结果::
$ bash ./show.sh
9 lines c.py => info from outside script
17 lines a.py => info from outside script
300 lines b withe spaces.py => info from outside script
1589 lines lib.py => info from outside script
1915 lines total => info from outside script
这很容易通过wc -l
排序::
$ wc -l *.py */*.py | sort -n
9 c.py
17 sub/a.py
300 b withe spaces.py
1589 lib.py
1915 total
所以我的出发点是::
array=(
$(find ./ -name "*.py" -print0 | while read -d $'\0' file
do
llines=$(cat $file | wc -l)
analyse='ouput analyse from some script'
printf "%s =\t%25s => %s" $llines $file $analyse
done
))
for item in ${array[@]}; do echo $item; done| sort -n
发生了什么?这不行吗?没有让你预期的产出?实际的问题不存在。 –