-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiskusage.sh
More file actions
executable file
·40 lines (26 loc) · 847 Bytes
/
Copy pathdiskusage.sh
File metadata and controls
executable file
·40 lines (26 loc) · 847 Bytes
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
#!/bin/bash
# Copyright (c) 2022-2026 R. Diez - Licensed under the GNU AGPLv3
#
# Script version 1.01.
set -o errexit
set -o nounset
set -o pipefail
declare -r SCRIPT_NAME="${BASH_SOURCE[0]##*/}" # This script's filename only, without any path components.
declare -r -i EXIT_CODE_ERROR=1
abort ()
{
echo >&2 && echo "Error in script \"$SCRIPT_NAME\": $*" >&2
exit "$EXIT_CODE_ERROR"
}
if (( $# == 0 )); then
abort "Missing arguments."
fi
printf -v QUOTED_PARAMS " %q" "$@"
# 'sort' options (use '--debug' to troubleshoot):
# b = ignore leading blanks, otherwise blanks (even separators) are included in the sorting
# hr = --human-numeric-sort and --reverse
# f = --ignore-case
declare -r CMD="du --bytes --human-readable --summarize --si $QUOTED_PARAMS | sort --key=1bhr,1 --key=2bf,2"
echo "$CMD"
echo
eval "$CMD"