add format mode only
This commit is contained in:
14
files/fastdu
14
files/fastdu
@@ -7,6 +7,7 @@ function helpexit() {
|
|||||||
echo " -s Summary mode, otherwise each argument folder calculated separate"
|
echo " -s Summary mode, otherwise each argument folder calculated separate"
|
||||||
echo " -c Count files instead of summarizing sizes"
|
echo " -c Count files instead of summarizing sizes"
|
||||||
echo " -a Display animation while counting"
|
echo " -a Display animation while counting"
|
||||||
|
echo " -f # Format filesize to human readable. Command exits without scanning."
|
||||||
echo " --help This help"
|
echo " --help This help"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
@@ -83,14 +84,25 @@ function displaysize() {
|
|||||||
# Get options
|
# Get options
|
||||||
what=()
|
what=()
|
||||||
for (( i=1; i<=$#; i++ )); do
|
for (( i=1; i<=$#; i++ )); do
|
||||||
|
[[ "${!i}" = "-a" ]] && { ANIMATE=1; continue; }
|
||||||
|
[[ "${!i}" = "-f" ]] && { FORMAT=1; ((i++)); FORMAT_VALUE=${!i}; continue; }
|
||||||
[[ "${!i}" = "--help" ]] && helpexit
|
[[ "${!i}" = "--help" ]] && helpexit
|
||||||
[[ "${!i}" = "-h" ]] && { HUMAN=1; continue; }
|
[[ "${!i}" = "-h" ]] && { HUMAN=1; continue; }
|
||||||
[[ "${!i}" = "-c" ]] && { COUNT=1; continue; }
|
[[ "${!i}" = "-c" ]] && { COUNT=1; continue; }
|
||||||
[[ "${!i}" = "-s" ]] && { SUMMARY=1; continue; }
|
[[ "${!i}" = "-s" ]] && { SUMMARY=1; continue; }
|
||||||
[[ "${!i}" = "-a" ]] && { ANIMATE=1; continue; }
|
|
||||||
what+=( "${!i}" )
|
what+=( "${!i}" )
|
||||||
done
|
done
|
||||||
[[ -z "${what[@]}" ]] && what="."
|
[[ -z "${what[@]}" ]] && what="."
|
||||||
|
# If formatting requested, do only that:
|
||||||
|
if [[ "$FORMAT" -eq 1 ]]; then
|
||||||
|
if [[ -z "$FORMAT_VALUE" ]]; then
|
||||||
|
echo -e "\nBytes argument missing\n\n"
|
||||||
|
helpexit
|
||||||
|
fi
|
||||||
|
filesize $FORMAT_VALUE
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
# If only one entry, dont print the name
|
# If only one entry, dont print the name
|
||||||
[[ "${#what[@]}" -eq 1 ]] && SUMMARY=1
|
[[ "${#what[@]}" -eq 1 ]] && SUMMARY=1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user