I've just built a script for that, it's not pretty but works for me.
I tested this script on Arch Linux with this configurations:
$ uname -a
Linux 4.4.13-1-lts #1 SMP Wed Jun 8 16:44:31 CEST 2016 x86_64 GNU/Linux
And my device name is
/dev/sdb which is quite different from yours, I hope
it will work for you as well.
Also note that this script depends on
usbutils package for
usb-devices program, I believe its installed by default on all linux, but i might be wrong.
# Input should be a single line from lsusb output:
# Read the bus number:
BUS=`echo $DATA | grep -Po 'Bus 0*\K[1-9]+'`
# Read the device number:
DEV=`echo $DATA | grep -Po 'Device 0*\K[1-9]+'`
# Search for the serial number of the PenDrive:
while read line
if [ $FOUND == true ]; then
USB_Serial=`echo "$line" | grep -Po 'SerialNumber=\K.*'`
if [ "$USB_Serial" != "" ]; then
if [ "`echo "$line" | grep -e "Bus=0*$BUS.*Dev#= *$DEV"`" != "" ]; then
done <<< "$(usb-devices)"
# Get the base name of the block device, e.g.: "sdx"
BASENAME=`file /dev/disk/by-id/* | grep -v 'part' | grep -Po "$USB_Serial.*/\K[^/]+$"`
# Build the full address, e.g.: "/dev/sdx"
# Output the address:
$ ./usbname "$(lsusb | grep '<my_usb_label_or_id>')"