Created
November 17, 2017 16:33
-
-
Save mzpqnxow/25548a91ebb1d6a2bf3a5bfe23a54c68 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 | |
# Print a list of all USB devices in Linux along with their | |
# manufacturer, product name and USB version (i.e. USBv2, USBv3) | |
# Set DEBUG to any value to enable printing of each command | |
# in case you get weird output | |
DEBUG="" | |
lsusb | while read line | |
do | |
bus=$(echo $line | cut -d ' ' -f 2) | |
device=$(echo $line | cut -d ' ' -f 4) | |
tmpfile=$(mktemp) | |
if [ "$DEBUG" != "" ] | |
then | |
echo "Executing 'lsusb -v -s $bus:$device'" | |
fi | |
sudo lsusb -v -s $bus:$device > $tmpfile; | |
product=$(cat $tmpfile | grep iProduct | head -1 | awk '{print $3}') | |
mfg=$(cat $tmpfile | grep iManufacturer | head -1 | awk '{print $3}') | |
usbv=$(cat $tmpfile | grep bcdUSB | head -1 | awk '{print $2}' | cut -d '.' -f 1) | |
if [ "$product" = "" -o "$mfg" = "" -o "$usbv" = "" ] | |
then | |
echo " --- SKIP DEVICE $bus:$device (missing values) ---" | |
continue | |
fi | |
echo "$mfg $product :: USBv$usbv" | |
rm -f $tmpfile | |
done |
Author
mzpqnxow
commented
Feb 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment