X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=smart-query.sh;h=e59836a792423c8d0b24dbf050e138e75673d4c4;hb=0c93539e382dc062a659390cebf32a835dbbe02d;hp=5cf62126948a900ccfd3b64328ce88efdafc1859;hpb=f7c2ce4501e383bcb23a8a623f88d136cbc810cc;p=gnt-info diff --git a/smart-query.sh b/smart-query.sh index 5cf6212..e59836a 100755 --- a/smart-query.sh +++ b/smart-query.sh @@ -1,17 +1,21 @@ -#!/bin/sh +#!/bin/sh -e -rm /tmp/s.last +test -e /tmp/s.last && rm /tmp/s.last -for col in "Device Model" "User Capacity" +for col in "Device Model" "User Capacity" $* do # sed and sort is required for join later - grep "$col" /dev/shm/smart.sda.* | sed 's/:/: /' | sed "s/$col: */ : /" | sort | tee /tmp/s.this + grep "$col" /dev/shm/smart.sd* | sed \ + -e "s/$col: */ : /" \ + -e "s/[0-9]* $col .* \([0-9][0-9]*\)$/ : \1/" \ + | sort > /tmp/s.this if [ -e /tmp/s.last ] ; then - join -a 1 /tmp/s.last /tmp/s.this | tee /tmp/s.new + join -a 1 /tmp/s.last /tmp/s.this > /tmp/s.new + mv /tmp/s.new /tmp/s.last else mv /tmp/s.this /tmp/s.last fi done -cat /tmp/s.new | column -t -s : +cat /tmp/s.last | sed -e 's!/dev/shm/smart.!!' -e 's/: : / : /'