title: BASH Increment MAC Address
body: <p>I've got a valid mac address in a var called <code>oldMAC</code>
  I need to increment this and then return a new valid MAC Address.</p>
  
  <p>In this example I'm incrementing by 1, but it could be by any value.</p>
  
  <p>So far I've got the following:</p>
  
  <pre><code>echo $oldMAC
  mac=$(echo $oldMAC |  tr '[:lower:]' '[:upper:]' | tr -d ':') # upper case and remove :
  echo $mac
  
  macdec=$( printf '%d\n' 0x$mac ) # convert to decimal
  echo $macdec
  
  macadd=$( expr $macdec + 1 ) # add 1
  echo $macadd
  
  machex=$( printf '%X\n' $macadd ) # convert to hex
  echo $machex
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>00:12:34:ae:BC:EF (oldMAC)
  001234AEBCEF (mac)
  78193278191 (macdec)
  78193278192 (madadd)
  1234AEBCF0 (machex)
  </code></pre>
  
  <p>The issue I have is working out how to convert <code>1234AEBCF0</code> so it returns as <code>00:12:34:AE:BC:F0</code></p>
  
  <p>Can anyone advise how to do this... or is there a better way ?</p>
  
  <p>Thanks</p>