Custom Search

Sunday, August 19, 2007

Drive Free Space Script

I originally got this script from:

http://64.233.169.104/search?q=cache:aIS0abHfbL4J:
techrepublic.com.com/i/tr/downloads/home/
milton_ingram_scripts.pdf+milton_ingram_scripts
&hl=en&ct=clnk&cd=1&gl=us&lr=lang_en&client=firefox-a

That's in html for convenience. There's also a pdf file:

http://techrepublic.com.com/i/tr/downloads/
home/milton_ingram_scripts.pdf

I changed it around a little. My way reads in gigabytes and I
dressed up the right side under 'Mounted on' to align left to
make it neater and look like the regular output of df.
You'll have to play around with the heading spacing on
Filesystem, Total, Used, and so forth. I'm no good at
html and besides, the formatting of this template on
my blog wouldn't allow the lines to appear as they do
in the script anyway. For instance, the ==== lines have
29 cut off the end to make it fit here. Any questions, I
can always send the script to anyone interested. I just
liked it since it helps me keep track of how much free
space I have.

#!/bin/ksh
# Generate a readable disk free listing
# MWI 0310
#
echo "======================================= "
echo "File System Report in GB :" `date`
echo "======================================= "
echo "Filesystem Total Used Avail Capacity Mounted on "
echo "======================================= "
df -k | sort -k6 |awk '$1!="swap" && $1!="Filesystem" \
{tt+=$2;tu+=$3;tr+=$4;printf "%-9s %10.2f %10.2f %10.2f %9s \
%-13s\n", $1, $2/1048576, $3/1048576, $4/1048576, $5, $6} \
END{printf "\nTotal GB %10.2f %10.2f %10.2f\n", tt/1048576, \
tu/1048576, tr/1048576 }'
echo "======================================= "

powered by performancing firefox

Labels:

0 Comments:

Post a Comment

<< Home