searchCD, fastdu upgrade, whatismyip.. try out!
This commit is contained in:
38
files/fastdu
38
files/fastdu
@@ -4,6 +4,7 @@ function helpexit() {
|
||||
echo "Display file/folder sizes like 'du', but faster and actual byte sizes"
|
||||
echo "Returns only the size as number"
|
||||
echo " -h Human readable units"
|
||||
echo " -s Summary mode, otherwise each argument folder calculated separate"
|
||||
echo " --help This help"
|
||||
exit
|
||||
}
|
||||
@@ -26,14 +27,31 @@ function filesize {
|
||||
}' || return $?
|
||||
}
|
||||
|
||||
[[ -z "$1" ]] && what="."
|
||||
[[ "$1" = "-h" ]] && { HUMAN=1; shift 1; }
|
||||
[[ "$1" = "--help" ]] && helpexit
|
||||
|
||||
SIZE=$( find $what "$@" -type f -printf %s"\n" | awk '{ sum += $1 } END { print int(sum)+0 }' )
|
||||
|
||||
[[ "$HUMAN" -eq 1 ]] && {
|
||||
filesize "$SIZE"
|
||||
exit
|
||||
function displaysize() {
|
||||
SIZE=$( find "$@" -type f -printf %s"\n" | awk '{ sum += $1 } END { print int(sum)+0 }' )
|
||||
[[ "$HUMAN" -eq 1 ]] && {
|
||||
SIZE=$( filesize "$SIZE" )
|
||||
}
|
||||
echo "$SIZE"
|
||||
}
|
||||
echo $SIZE
|
||||
|
||||
# Get options
|
||||
what=()
|
||||
for (( i=1; i<=$#; i++ )); do
|
||||
[[ "${!i}" = "--help" ]] && helpexit
|
||||
[[ "${!i}" = "-h" ]] && { HUMAN=1; continue; }
|
||||
[[ "${!i}" = "-s" ]] && { SUMMARY=1; continue; }
|
||||
what+=( "${!i}" )
|
||||
done
|
||||
[[ -z "${what[@]}" ]] && what="."
|
||||
|
||||
if [[ "$SUMMARY" -eq 1 ]]; then
|
||||
# Display one line
|
||||
displaysize "${what[@]}"
|
||||
else
|
||||
# One size for each argument
|
||||
for dir in "${what[@]}"; do
|
||||
printf "%s\t%s\n" "$( displaysize "$dir" )" "$dir"
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user