#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG 7.0				#
#							#
# Licensed under GNU LESSER GENERAL PUBLIC LICENSE v3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

case $1 in 
	*used)
		free -m | grep 'buffers/cache' | awk '{print $3}'
	;;

	*free)
		free -m | grep 'buffers/cache' | awk '{print $4}'
	;;
	
	*percent-used)
		free | {
		read
		read m t u f s b c;
		f=$[$f + $b + $c]
		f=$[100-100*$f/$t]
		if [ $f -gt 100 ]; then
			f=100
		fi
		echo ${f}%
		}
	
	;;
	
	*precent-free)
		free | {
		read
		read m t u f s b c;
		f=$[$f + $b + $c]
		f=$[100-100*$f/$t]
		if [ $f -gt 100 ]; then
			f=100
		fi
		echo $((100-${f}))%
		}
	;;
esac
