Skip to content

Instantly share code, notes, and snippets.

@mzpqnxow
Created November 17, 2017 16:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzpqnxow/25548a91ebb1d6a2bf3a5bfe23a54c68 to your computer and use it in GitHub Desktop.
Save mzpqnxow/25548a91ebb1d6a2bf3a5bfe23a54c68 to your computer and use it in GitHub Desktop.
#!/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
@mzpqnxow
Copy link
Author

Realtek USB3.0 :: USBv3
Linux xHCI :: USBv3
     --- SKIP DEVICE 001:007: (missing values) ---
Chicony EasyCamera :: USBv2
Cisco Linksys :: USBv2
     --- SKIP DEVICE 001:003: (missing values) ---
     --- SKIP DEVICE 001:006: (missing values) ---
Logitech USB :: USBv2
Realtek USB3.0 :: USBv2
Linux xHCI :: USBv2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment