Created
March 17, 2023 14:20
-
-
Save nbuchwitz/1c8c67311cf701df0e7a7b9629b14abb to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
VENDOR_ID=2109 | |
PRODUCT_ID=2817 | |
# find all devices which match our product id | |
for f in $(grep --include='idProduct' -rlw "$PRODUCT_ID" /sys/bus/usb/devices/usb* 2>/dev/null); do | |
device=$(dirname $f) | |
# ensure that vendor id also matches | |
if [[ $(cat ${device}/idVendor) != $VENDOR_ID ]]; then | |
continue | |
fi | |
# basename of the sysfs path is our device path | |
# the root port is stripped from the device path (part before the first dash) | |
devpath=$(basename $device | cut -f 2 -d -) | |
echo $devpath | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment