slitaz-dev-tools view baba-scripts/xdf @ rev 247
tazwikiss: large page support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Sep 02 21:21:36 2015 +0200 (2015-09-02) |
parents | |
children |
line source
1 #!/bin/sh
2 field() {
3 textwidth=`length "$1"`
4 freewidth=$(( $2 - $textwidth ))
5 fieldtext="$1"
6 position=${3-after}
7 for i in `seq 1 $freewidth`; do
8 case $position in
9 before) fieldtext=" $fieldtext" ;;
10 after) fieldtext="$fieldtext " ;;
11 esac
12 done
13 echo "$fieldtext"
14 }
15 #df -h | grep ^/dev/ | grep -v ^/dev/root | sed "s/ \+/ /g" | while read line; do
16 df -h | grep ^/dev/ | sed "s/ \+/ /g" | while read line; do
17 device=`echo $line | cut -d' ' -f1`
18 device=`field $device 8`
19 size=`echo $line | cut -d' ' -f2`
20 size=`field $size 6 before`
21 used=`echo $line | cut -d' ' -f3`
22 used=`field $used 6 before`
23 free=`echo $line | cut -d' ' -f4`
24 free=`field $free 6 before`
25 usepercent=`echo $line | cut -d' ' -f5`
26 usebar="|"
27 counter=`expr ${usepercent%\%} '/' 10`
28 for i in `seq 1 $counter`; do
29 usebar="${usebar}>"
30 done
31 for i in `seq $counter 9`; do
32 usebar="${usebar}."
33 done
34 usebar="${usebar}|"
35 usepercent=`field $usepercent 4 before`
36 mntpoint=`echo $line | cut -d' ' -f6`
37 mntpoint=`field "($mntpoint)" 20`
38 echo "$device $mntpoint $used/$size $usebar $usepercent - $free free"
39 done