From cecbbff88d036c84934ab8523bc5e820d54d8596 Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Thu, 23 Apr 2020 17:10:18 +0000 Subject: [PATCH] refactored to remove redundent code. --- df-custom.sh | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/df-custom.sh b/df-custom.sh index 5cde83d..82c0f4e 100755 --- a/df-custom.sh +++ b/df-custom.sh @@ -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