Friday, September 18, 2015

This script is a one-liner that can display free space in a human readable format.

Usage: dfy sda

\#!/bin/bash
\#

echo "  drive $1 mountpoint      gigbytes " | awk ''{printf $0 "\\n\\n"}''; df -Tx tmpfs |grep $1 | sort -rnk 5 |awk ''{gb += $5} {gt += $3} {  printf " %-10s %-15s* %7.3f free of %7.3f\\n", $1, $7, (($5/1024)/1024),(($3/1024)/1024)  } END {printf ( "\\nTotal GB = %4.2f free of %4.2f \\n\\n", (gb/1024)/1024 , (gt/1024)/1024 )}'';


\#end of script

No comments:

Post a Comment