title: How to get just USB IDs of all plugged in devices in linux
body: <p>I am trying to make a Python script which runs in the background and checks the USB IDs of all plugged in devices to see if it matches a list of recognized IDs. This is going to be ran in a Linux environment with preferably Python 2.x</p>
  
  <p>I know in in linux I can run <code>lsusb</code> in a shell or run it through <code>os.system()</code> and that will give me this output:</p>
  
  <pre><code>Bus 003 Device 009: ID 046d:c534 Logitech, Inc. Unifying Receiver
  Bus 003 Device 007: ID 046d:082b Logitech, Inc. Webcam C170
  Bus 003 Device 005: ID 1532:0043 Razer USA, Ltd 
  Bus 003 Device 010: ID 05e3:0608 Genesys Logic, Inc. Hub
  Bus 003 Device 008: ID 05e3:0608 Genesys Logic, Inc. Hub
  Bus 003 Device 006: ID 0424:2137 Standard Microsystems Corp. 
  Bus 003 Device 004: ID 0451:8044 Texas Instruments, Inc. 
  </code></pre>
  
  <p>However, as you can see this returns way more information than I need and filtering through this will be difficult and take more time. What i need would be something like this:</p>
  
  <pre><code>046d:c534
  046d:082b
  1532:0043
  05e3:0608
  05e3:0608
  0424:2137
  0451:8044
  </code></pre>
  
  <p>In the interest of keeping this script as fast as possible, is there some way that I can run a command to the system and get back just the USB IDs of everything plugged in, or use <code>grep</code> or something similar in Python to filter through it somehow?</p>
  
  <p>Thanks in advance!</p>