Garl GrigsbyWed Jul 28 16:23:43 PDT 2004
Bob Miller wrote:
> You don't need awk for that. You could do something like this if
>
>you wanted to process each USB device separately.
>
> for unit in /proc/scsi/usb-storage-*/*
> do
> while read name value
> do
> case "$name" in
> GUID:) guid="$value";;
> Attached:) attached="$value";;
> esac
> done < "$unit"
> echo ${unit}: GUID: $guid attached: $attached
> # do something useful for one unit here.
> done
>
>
>
Bob,
I owe you a beer. This (above) was almost exactly what I needed.
What you showed me above didn't completely work, and why it doesn't work
is still a mystery to me, but I made the following modifications and how
it does work.
for unit in /proc/scsi/usb-storage-*/*
do
cat $unit > /tmp/unit
while read name value
do
case "$name" in
GUID:) guid="$value";;
Attached:) attached="$value";;
esac
done < /tmp/unit
echo ${unit}: GUID: $guid attached: $attached
# do something useful for one unit here.
done
The way you had it the read would stop just after the Protocol line. It
would never process the Transport, GUID, or the Attached lines. Again, I
have no idea why this is happening. I can't find anything in there that
would cause it to fail but it did. Any way, this works, and works well.
Thanks again,
garl