1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 05:59:04 -08:00
rc/sh/dbusiest

29 lines
656 B
Text
Raw Normal View History

#!/usr/bin/env zsh
2021-07-29 00:37:35 -07:00
# YES_ZSH
# NO_BASH
# NO_DASH
2021-09-23 06:48:05 -07:00
# NO_ASH
2021-07-29 00:37:35 -07:00
2021-07-30 17:57:08 -07:00
dbusiest() { ### @-
2021-08-01 08:32:45 -07:00
### list directories ordered descending by the number of files in them,
### counted recursively. see also [`cdbusiest`.](#cdbusiest)
###
### ```
### $ cd
### $ dbusiest | head -n3
### 152364 src
### 46518 work
### 20903 play
### ```
2021-07-29 00:37:35 -07:00
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
local c d
for d in *(FDN); do
print $(find $d 2>/dev/null | wc -l) $d
done | sort -nr | while read c d; do
echo -E $c $d
done
[ -z $d ] && return 1
}
[ -n "${preload+-}" ] || dbusiest "$@"