d (du), f (df) and tohuman scripts.

master
Karchnu 2022-02-03 00:05:54 +01:00
parent 33df582db7
commit f927499e22
3 changed files with 44 additions and 0 deletions

4
sh/d Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
# du = sizes in Ko
du -s * | awk '{$1*=1000; print}' | sort -n | tohuman | column -t

3
sh/f Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
df -h .

37
sh/tohuman Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
tohuman() awk -v COL=$1 '{
raw = $COL
new = raw
for (i=1; i<6;i++) {
if (raw >= 1000**i) {
if (i == 1) {
v = raw / 1000
new = v "K"
}
if (i == 2) {
v = raw / 1000000
new = v "M"
}
if (i == 3) {
v = raw / 1000000000
new = v "G"
}
if (i == 4) {
v = raw / 1000000000000
new = v "T"
}
if (i == 5) {
v = raw / 1000000000000000
new = v "P"
}
}
}
$1 = new
print
}'
col=${1:-1}
tohuman "$col"