From 81044e696b75716fadeb267575f5cabd53f1c04a Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Thu, 23 Apr 2020 03:46:34 +0000 Subject: [PATCH] pretty df --- df-custom.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 df-custom.sh diff --git a/df-custom.sh b/df-custom.sh new file mode 100755 index 0000000..5cde83d --- /dev/null +++ b/df-custom.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +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" + + 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" + +done +