I want check the free space in my hard disk. Suppose I'm having
10GB HDD, I used only 7GB. I want check how much remaining space
is available. Any command available for that.
df -k
du -sk directory
#!/bin/ksh
MAILTO="user@host.com"
echo "df -k output for `date` `uname -a`" > /tmp/df.out
case `uname -s` in
SunOS | Linux | OSF1 | UNIX_SV | FreeBSD )
if [ -s "/etc/redhat-release" ] ; then cat /etc/redhat-release >> /tmp/df.out
; fi
set -- `df -k | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n",
$5, $6) }'`
;;
HP-UX )
set -- `bdf | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n", $5,
$6) }'`
;;
AIX )
set -- `df -k | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n",
$4, $7) }'`
;;
esac
while [ $# -ge 2 ] ; do
CAPACITY=$1
FS=$2
shift 2
if [ $CAPACITY -gt 90 ] ; then
echo "$FS is at $CAPACITY %" >> /tmp/df.out
fi
done
if [ `wc -l /tmp/df.out | awk '{ print $1 }'` -ge 2 ] ; then
cat /tmp/df.out | mail -s "`date`" $MAILTO
fi
I sometimes prefer a "human readable" output which
can be performed by adding an "h" switch:
$ df -h
Quick Links:
Do
you have a Linux Question?
Linux Home: Linux System Administration Hints and Tips