title: Android get emulator given name of device, or vice versa
body: <p>Currently when I run <code>adb devices</code> it gives me a list of devices that looks something like:</p>
  
  <pre><code>emulator-5554    device
  emulator-5556    device
  </code></pre>
  
  <p>My goal is to find a command that I can run in the shell that takes a device name as a parameter, e.g. <code>Nexus7</code> and returns the corresponding device serial, e.g. <code>emulator-5554</code>.  If that isn't possible, I want to be able to have a function that takes <code>emulator-5554</code> as the parameter and returns <code>Nexus7</code> (the opposite direction of the former function) which I will then loop over all the devices in <code>adb devices</code> and figure out which one matches <code>Nexus7</code>.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I found a workaround solution which was to specify the port number when I launch the avd and then I know which emulator maps to which avd name, but ideally I would still like to know the answer here.</p>