title: Get string from adb shell and use string as value in setting next command
body: <p>I am trying to automate some batch scripting that I want to:</p>
  
  <ol>
  <li><p>Get the WLAN mac address of an android device using <code>adb shell ip
  address show wlan0</code></p></li>
  <li><p>Set the android device's name to the last three octets of the mac
  address so it is easy to identify the device using <code>adb shell
  settings put global device_name TAB3-&lt;last three octets&gt;</code></p></li>
  </ol>
  
  <p>The mac address is always on the second line of the output of the following:</p>
  
  <pre><code>adb shell ip address show wlan0
  8: wlan0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP group default qlen 3000
      link/ether 14:9f:3c:ca:dd:ce brd ff:ff:ff:ff:ff:ff
      inet 172.29.14.16/23 brd 172.29.15.255 scope global wlan0
         valid_lft forever preferred_lft forever
      inet6 fe80::169f:3cff:feca:ddce/64 scope link
         valid_lft forever preferred_lft forever
  </code></pre>
  
  <p>I would like to get that last three octets, e.g. <code>ca:dd:ce</code> and then set the device name using those last three octets but without the colons appended onto the string <code>TAB3-</code>, e.g.:</p>
  
  <p><code>adb shell settings put global device_name TAB3-caddce</code></p>
  
  <p>I have been digging into bash scripting but I am really not getting how to actually read the last three octets of the mac address.  The OUI <code>14:9f:3c</code> should stay the same all the time.</p>
  
  <p>This is how far I've gotten to actually reading the second line of the output and storing it in a variable but unsure how to proceed past this?</p>
  
  <pre><code>echo on
  
  for /f "skip=1 tokens=*" %%a in ('adb shell ip address show wlan0') do (
      if not defined second_line set "second_line=%%a"
  )
  
  echo %second_line%
  </code></pre>