Created
February 26, 2021 23:36
-
-
Save Higgs1/fa483adfa58f4b2955f13e57efec4087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_dev_by_usb_id() { | |
idV=${1%:*} | |
idP=${1#*:} | |
for path in $(find /sys/ -name idVendor 2> /dev/null | rev | cut -d/ -f 2- | rev); do | |
if grep -q $idV $path/idVendor; then | |
if grep -q $idP $path/idProduct; then | |
for bd in $(find $path -name 'device' | grep 'block' | rev | cut -d / -f 2 | rev); do | |
echo "/dev/$bd" | |
done | |
fi | |
fi | |
done | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment