2020-12-29 08:38:07 -08:00
|
|
|
#!/usr/bin/env zsh
|
2024-07-22 05:28:58 -07:00
|
|
|
# compat: -ash -bash -dash +zsh
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-09-28 13:12:03 -07:00
|
|
|
busiest() { ### @-
|
|
|
|
### list directories in descending order by the number of files in them,
|
|
|
|
### counted recursively.
|
2021-08-01 08:32:45 -07:00
|
|
|
###
|
|
|
|
### ```
|
2021-09-28 13:12:03 -07:00
|
|
|
### $ cd && busiest | head -n3
|
|
|
|
### 144181 src
|
|
|
|
### 48840 work
|
|
|
|
### 21042 play
|
2021-08-01 08:32:45 -07:00
|
|
|
### ```
|
2021-07-29 00:37:35 -07:00
|
|
|
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
|
2021-09-30 08:43:40 -07:00
|
|
|
local c= d=
|
2021-07-29 00:37:35 -07:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-09-28 13:12:03 -07:00
|
|
|
[ -n "${preload+-}" ] || busiest "$@"
|