Skip to content

Instantly share code, notes, and snippets.

@etcwilde
Created April 5, 2016 20:20
Show Gist options
  • Save etcwilde/1277133506bcb961f9f475670662fe0c to your computer and use it in GitHub Desktop.
Save etcwilde/1277133506bcb961f9f475670662fe0c to your computer and use it in GitHub Desktop.
Lookup serial devices connected to the serial port
#!/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/"* ]] && continue
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && continue
echo "/dev/$devname - $ID_SERIAL"
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment