I am trying to run a usbreset program against lsusb which has several devices with the same device identifier.
I run lsusb to list the devices, and add a | grep [identifer] to only list the devices with that identifier.
I need to then run an awk command to get the bus and device number, which will be inserted into a usbreset program (https://github.com/jkulesza/usbreset) which will reset all of the devices that match the id.
The command looks like this:
lsusb | grep 1234:a1b1 | while read line ; do awk -F '[^0-9]+' '{ system("sudo ./usbreset /dev/bus/usb/002/"$3) }'; done
where -F '[^0-9]+' helps remove the ":" from the end of the device number, and $3selects the fourth column of the lsusb command output: Bus 002 Device 010: ID 1234:a1b1
This works nicely, but the issue I have is that i have 6 devices with this id, and the awk command cuts off the first result, and only prints 5.
user@localhost:~$ lsusb | grep 1234:a1b1
Bus 002 Device 015: ID 1234:a1b1
Bus 002 Device 014: ID 1234:a1b1
Bus 002 Device 013: ID 1234:a1b1
Bus 002 Device 010: ID 1234:a1b1
Bus 002 Device 009: ID 1234:a1b1
Bus 002 Device 008: ID 1234:a1b1
and:
user@localhost:~$ lsusb | grep 1234:a1b1 | while read line ; do awk -F '[^0-9]+' '{ print $3 }'; done
014
013
010
009
008
Any advice to help find out where I am going wrong with this would be great!