slitaz-dev-tools diff baba-scripts/xdf @ rev 145
rolling.sh: add loram support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Mar 02 10:13:50 2012 +0100 (2012-03-02) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/baba-scripts/xdf Fri Mar 02 10:13:50 2012 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +#!/bin/sh 1.5 +field() { 1.6 + textwidth=`length "$1"` 1.7 + freewidth=$(( $2 - $textwidth )) 1.8 + fieldtext="$1" 1.9 + position=${3-after} 1.10 + for i in `seq 1 $freewidth`; do 1.11 + case $position in 1.12 + before) fieldtext=" $fieldtext" ;; 1.13 + after) fieldtext="$fieldtext " ;; 1.14 + esac 1.15 + done 1.16 + echo "$fieldtext" 1.17 +} 1.18 +#df -h | grep ^/dev/ | grep -v ^/dev/root | sed "s/ \+/ /g" | while read line; do 1.19 +df -h | grep ^/dev/ | sed "s/ \+/ /g" | while read line; do 1.20 + device=`echo $line | cut -d' ' -f1` 1.21 + device=`field $device 8` 1.22 + size=`echo $line | cut -d' ' -f2` 1.23 + size=`field $size 6 before` 1.24 + used=`echo $line | cut -d' ' -f3` 1.25 + used=`field $used 6 before` 1.26 + free=`echo $line | cut -d' ' -f4` 1.27 + free=`field $free 6 before` 1.28 + usepercent=`echo $line | cut -d' ' -f5` 1.29 + usebar="|" 1.30 + counter=`expr ${usepercent%\%} '/' 10` 1.31 + for i in `seq 1 $counter`; do 1.32 + usebar="${usebar}>" 1.33 + done 1.34 + for i in `seq $counter 9`; do 1.35 + usebar="${usebar}." 1.36 + done 1.37 + usebar="${usebar}|" 1.38 + usepercent=`field $usepercent 4 before` 1.39 + mntpoint=`echo $line | cut -d' ' -f6` 1.40 + mntpoint=`field "($mntpoint)" 20` 1.41 + echo "$device $mntpoint $used/$size $usebar $usepercent - $free free" 1.42 +done