Skip to content

Instantly share code, notes, and snippets.

@pnlybubbles
Last active March 6, 2021 11:25
Show Gist options
  • Save pnlybubbles/9aa5958427ac67ac21e9c03f02bdbe28 to your computer and use it in GitHub Desktop.
Save pnlybubbles/9aa5958427ac67ac21e9c03f02bdbe28 to your computer and use it in GitHub Desktop.
Get device serial from /dev/tty* mirror: https://unix.stackexchange.com/a/144735
#!/bin/bash
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
syspath="${sysdevpath%/dev}"
devname="$(udevadm info -q name -p $syspath)"
[[ "$devname" == "bus/"* ]] && exit
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && exit
echo "/dev/$devname - $ID_SERIAL"
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment