title: BASH: set multiple variables at once / performance
body: <p>I am running bash scripts on windows using a msys and mingw environment.  I have seem to have an issue where using a command like 'cut' or sed' causes an overhead for each call.  I'm not sure if this is an effect of windows running .exe's or what.  anyways here is my code:</p>
  
  <pre><code>SOMETHING=`m6811-elf-readelf.exe -l "${TARGET_BASENAME}.elf" | sed '1,/Type / d' | sed '1,/^$/!d'`
  
  echo "$SOMETHING" | while read -r line; do 
      # MEMORY_ADDRESSES=`echo $line | sed -ne 's/LOAD[^0-9a-z]*0x\([^ ]*\) 0x\([^ ]*\) 0x\([^ ]*\) 0x\([^ ]*\) 0x\([^ ]*\) .*/\1 \2 \3 \4 \5/p;'`
       OFFSET=`echo "$line" | cut -f12 -d\ `
       VIRTADDR=`echo "$line" | cut -f13 -d\ `
       PHYSADDR=`echo "$line" | cut -f14 -d\ `
       FILESIZE=`echo "$line" | cut -f15 -d\ `
       MEMSIZE=`echo "$line" | cut -f16 -d\ `
       echo $OFFSET $VIRTADDR $PHYSADDR $FILESIZE $MEMSIZE 
  done
  </code></pre>
  
  <p>I would like to get this running as fast as possible.  I thought that the sed line was slowing me down, so I removed it and I am just using cut.  For every cut line that I use, this code is much slower.</p>
  
  <p>The contents of the SOMTHING variable are:</p>
  
  <pre><code>  LOAD           0x000000 0x00000000 0x00000000 0x00680 0x00680 RW  0x1000
    LOAD           0x001100 0x00002100 0x00002100 0x00000 0x0005a R   0x1000
    LOAD           0x00115a 0x0000215a 0x0000215a 0x00615 0x00669 RWE 0x1000
    LOAD           0x002000 0x00010000 0x00008000 0x00056 0x00056 R E 0x1000
    LOAD           0x003000 0x00018000 0x00028000 0x03ffe 0x03ffe R E 0x1000
    LOAD           0x007000 0x0001c000 0x00038000 0x03e60 0x03e60 R E 0x1000
    LOAD           0x00b000 0x00020000 0x00048000 0x021b5 0x021b5 R E 0x1000
    LOAD           0x00e000 0x00024000 0x00058000 0x0236a 0x0236a R E 0x1000
  </code></pre>
  
  <p>The purpose of this code is to extract each hex address from the $SOMETHING output so I can do some simple math.  As this file gets longer (up to 20 lines) it gets pretty slow.</p>
  
  <p>If you know an efficient way for me to assign the OFFSET,VIRTADDR,PHYSADDR etc variables, it would help a lot!!</p>