test of output

This commit is contained in:
inxi-svn 2009-01-09 02:07:19 +00:00
parent 5b246b5dd7
commit 1948f9df0e

33
inxi
View file

@ -1861,17 +1861,18 @@ get_hdd_data_basic()
{ {
local hdd_used='' local hdd_used=''
# dfdata="Filesystem 1K-blocks Used Available Use% Mounted on dfdata="Filesystem 1K-blocks Used Available Use% Mounted on
# /dev/hdc7 5289348 2811800 2208864 57% / /dev/hdc7 5289348 2811800 2208864 57% /
# tmpfs 1037688 0 1037688 0% /lib/init/rw tmpfs 1037688 0 1037688 0% /lib/init/rw
# udev 10240 116 10124 2% /dev udev 10240 116 10124 2% /dev
# tmpfs 1037688 0 1037688 0% /dev/shm tmpfs 1037688 0 1037688 0% /dev/shm
# /dev/hdc8 8420132 4218360 3774044 53% /home /dev/hdc8 8420132 4218360 3774044 53% /home
# /dev/hdc5 32981408 20955204 12026204 64% /media/hd2 /dev/hdc5 32981408 20955204 12026204 64% /media/hd2
# /dev/sdb1 390700768 188926868 201773900 49% /media/Snusmumrikken /dev/sdb1 390700768 188926868 201773900 49% /media/Snusmumrikken
# /dev/sda1 732572000 248156936 484415064 34% /media/Mr. Big" /dev/sda1 732572000 248156936 484415064 34% /media/Mr. Big"
# hdd_used=$( echo "$dfdata" | gawk ' # hdd_used=$( df | gawk '
hdd_used=$( df | gawk ' hdd_used=$( echo "$dfdata" | gawk '
/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ { /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ {
# this handles the case where the first item is too long # this handles the case where the first item is too long
# and makes df wrap output to next line, so here we advance # and makes df wrap output to next line, so here we advance
@ -1879,25 +1880,29 @@ get_hdd_data_basic()
if ( NF == 1 ) { if ( NF == 1 ) {
getline getline
} }
if ( $4 ~ /.*\%/ ) { if ( $4 ~ /.*\%/ ) {
used += $2 used += $2
available += $3
print "b: " $1
} }
else if ( $5 ~ /.*\%/ ) { else if ( $5 ~ /.*\%/ ) {
used += $3 used += $3
available += $4
print "a: " $1
} }
else { else {
next next
} }
} }
END { END {
print used print "used: " used
print "available: " available
}' ) }' )
if [[ -z $hdd_used ]];then if [[ -z $hdd_used ]];then
hdd_used='na' hdd_used='na'
fi fi
echo hdd_used $hdd_used echo hdd_used "$hdd_used"
# create the initial array strings: # create the initial array strings:
# disk-dev, capacity, name, usb or not # disk-dev, capacity, name, usb or not