I am trying to write a bash
script which can detect they number of keyboards currently connected to my MacBook Pro. The keyboards can be the
Please give me any suggestions or areas I should be looking for. I am currently using a 2015 MacBook Pro running OSX 10.12.5. I am using the default terminal running bash 4.
The ioreg
command can be used to get a tree of all connected USB devices:
ioreg -p IOUSB
You can use sed
to extract just the device names and grep
to filter out the root nodes from the tree.
ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With