Command 1:
lsusb | awk '{print $6}'
Output 1:
1d6b:0002
0627:0001
0627:0001
0627:0001
0409:55aa
46f4:0001
1d6b:0003
1d6b:0002
1d6b:0003
Command 2:
lsusb | awk '{print $6}' | xargs
Output 2:
1d6b:0002 0627:0001 0627:0001 0627:0001 0409:55aa 46f4:0001 1d6b:0003 1d6b:0002 1d6b:0003
But command 3:
lsusb | awk '{print $6}' | xargs --null lsusb -s
Output 3:
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
And command 4:
lsusb | awk '{print $6}' | xargs --null lsusb -d
Output 4:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
I expect:
folkertmeeuw@fedora:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 003: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 004: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 005: ID 0409:55aa NEC Corp. Hub
Bus 001 Device 006: ID 46f4:0001 QEMU QEMU USB HARDDRIVE
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Several issues:
xargs --null
while your awk
script separates the outputs with newlines, not null characters.lsusb -s
but you pass it vendor:product
specifications, not bus:device
specifications.-n1
option of xargs
because lsusb -s
(or lsusb -d
) accepts only one bus:devnum
(or vendor:product
) specification.If you want to use vendor:product
specifications try:
lsusb | awk '{print $6}' | xargs -n1 lsusb -d
Or, to avoid duplicate outputs:
lsusb | awk '!seen[$6]++ {print $6}' | xargs -n1 lsusb -d
If you want to use bus:device
specifications try:
lsusb | awk '{sub(/:$/, "", $4); print $2 ":" $4}' | xargs -n1 lsusb -s