-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdfcsort
executable file
·50 lines (40 loc) · 916 Bytes
/
dfcsort
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
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# Deps
# dfc https://github.com/rolinh/dfc
usage() {
cat << EOF
dfcsort: Report file system space usage in a fancy way when you have a fuck ton of drives. It's for Chia. And only if your mountpoints are named /mnt/{plots-plots155}.
Usage: dfcsort [-s]
-s Sort devices sequentially by their mountpoint
EOF
exit 1
}
function dfcsort() {
echo ""
dfc -p /dev -q name -Tflms -c always | \
sort -n -k 7.17 | \
sed '2{2h;1H;d};$G' | \
sed -n '2{h;n;G};p' | \
sed -n '3{h;n;G};p'
echo ""
}
function seqcheck() {
awk '{for(i=p+1; i<$1; i++) print i} {p=$1}'
}
OPTSTR='s'
while getopts "$OPTSTR" opt; do
case "$opt" in
s)
SEQCHECK=true
;;
*)
usage
;;
esac
done
if [[ $SEQCHECK == true ]]; then
echo "mountpoints missing from sequence:"
dfcsort | awk '{print $7}' | cut -d / -f4 | grep plots |cut -c 6- | seqcheck
else
dfcsort
fi