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
發生了什麼?這不行嗎?沒有讓你預期的產出?實際的問題不存在。 –