mangar
January 22nd, 2009, 11:29 AM
I'm trying to locate a specific device with in /Sys, according to the vendor Id.
Since the device got several subssystems, I get a list of files, while I need the lexicographically smallest directory name(since it's the first device in the pci-e tree).
How do I get the lexicographically smallest directory name?
source:
#!/bin/sh
for i in `grep -li -m 1 $1 /sys/bus/pci/devices/*/vendor` ; do
k=`dirname $i`
if grep -qi $2 $k/device ; then j="$j $k" ; fi
done
echo $j
Is there a way to do it from a binary file?
Since the device got several subssystems, I get a list of files, while I need the lexicographically smallest directory name(since it's the first device in the pci-e tree).
How do I get the lexicographically smallest directory name?
source:
#!/bin/sh
for i in `grep -li -m 1 $1 /sys/bus/pci/devices/*/vendor` ; do
k=`dirname $i`
if grep -qi $2 $k/device ; then j="$j $k" ; fi
done
echo $j
Is there a way to do it from a binary file?