refactored to remove redundent code.

This commit is contained in:
2020-04-23 17:10:18 +00:00
parent e18be3dc61
commit cecbbff88d
+4 -14
View File
@@ -1,24 +1,14 @@
#!/bin/bash
LOCATION=`dirname "$0"`
if (( "0" == "$#" )); then
device="/"
usage=`df --output=pcent $device | tail -n 1 | grep -oE '[0-9]+'`
open=`echo "100 - $usage" | bc`
avail=`df --output=avail -h $device | tail -n 1`
echo "Available: $avail ($open%) $device"
source "${LOCATION}/storage.sh" "$device"
exit
fi
for device in "$@"; do
usage=`df --output=pcent $device | tail -n 1 | grep -oE '[0-9]+'`
open=`echo "100 - $usage" | bc`
avail=`df --output=avail -h $device | tail -n 1`
echo "Available: $avail ($open%) $device"
source "${LOCATION}/storage.sh" "$device"
done