我正在使用以下代码来显示索引节点和磁盘空间。它工作正常,但我想将计数从最大到最小排序。我需要进行哪些更改?
我试图添加sort | uniq -c | sort -rn
,但是它不起作用。
for DIR in `find $CURDIR -maxdepth 1 -type d |grep -xv $CURDIR |sort`; do
COUNT=$(GET_COUNT $DIR)
SIZE=$(GET_SIZE $DIR)
# Check if exclude arg was used, and if so only output directories above exclude inode count
if [[ -z $exclude ]] || [[ -n $exclude && $COUNT -gt $exclude ]]
then
printf "$format" " $COUNT" " $SIZE" "`basename $DIR`"
fi
我需要使索引节点和磁盘大小从最大到最小。
[而不是处理循环中的每个文件夹,请考虑结合使用'find ... -printf',并将其与适当的表达式组合以进行过滤(针对排除规则)
find $CURDIR -mindepth 1 -maxdepth 1 - type d -links +${exclude-0} -printf '%n %s %f\n'
如果
例如:
exclude=2
find . -mindepth 1 -maxdepth 1 -type d -links +${exclude+0} -printf '%n %s %f\n'
Output:
3 4096 a
3 4096 b