-
Notifications
You must be signed in to change notification settings - Fork 1
/
iu
executable file
·42 lines (35 loc) · 848 Bytes
/
iu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
set -euo pipefail
usage() {
>&2 cat <<HELP
Usage: $(basename "$0") [filepath [...]]
Like 'du -s ...' but counts inodes rather than blocks.
If no arguments are provided, defaults to list of directories
that are immediate children of the current working directory.
HELP
}
TOPS=()
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage
exit 0
;;
*)
TOPS+=("$1")
;;
esac
shift
done
# use gfind if it's available
if command -v gfind >/dev/null 2>&1; then
# FIXME: there's probably a better way to support multiple platforms
shopt -s expand_aliases
alias find=gfind
fi
if [[ ${#TOPS[@]} -eq 0 ]]; then
mapfile -t TOPS < <(find . -mindepth 1 -maxdepth 1 -type d -printf '%f\n')
fi
for TOP in "${TOPS[@]}"; do
printf '%d\t%s\n' "$(find "$TOP" -printf 0 | wc -c)" "$TOP"
done