new space util
This commit is contained in:
24
utils/.local/bin/space
Executable file
24
utils/.local/bin/space
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [-h] PATH [-N]
|
||||
|
||||
Display used space on disk by PATH or show top N most heavy paths inside a PATH
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
du -ah "$1" 2>/dev/null \
|
||||
| sort -rh 2>/dev/null \
|
||||
| head -"$2" 2>/dev/null
|
||||
else
|
||||
du -ah --max-depth=1 "$1" 2>/dev/null \
|
||||
| sort -rh 2>/dev/null
|
||||
fi
|
||||
Reference in New Issue
Block a user