title: Set Counter Value
body: <p>Hello Programming Profi,
  i would like to have the counter value in total and in last in second echo of the script but the counter is runnung in do function.
  is there a way to let it write the value before the do function .
  or if i write the first 2 echo lines under counter i got the value but i need to write this line on top of xml files!
  is there a way to do that , maybe counter value from middel the script to the total and last on echo second line .</p>
  <pre><code>#XML headers
  echo '&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;' &gt; $tmp_gigabook
  echo &quot;&lt;list response=\&quot;get_list\&quot; type=\&quot;pr\&quot; reqid=\&quot;1000\&quot; total=\&quot;$counter\&quot; first=\&quot;1\&quot; last=\&quot;$counter\&quot;&gt;&quot; &gt;&gt; $tmp_gigabook
  declare counter=1000
  # Read intermediate csv-xml-ish into array of lines
  readarray -t lines &lt; $tmp_intermediate
  # Walk through lines and output entries
  for line in &quot;${lines[@]}&quot;
  do
      # Split line into columns
      # Fix v 0.3 Parentheses bug: explicitly set IFS, don't rely on defaults
      IFS=$'\t'
      read -a columns &lt;&lt;&lt; &quot;$line&quot;
      # Output xml
  
  ((counter++))
  
      echo &quot;&lt;entry id=\&quot;$counter\&quot;&gt;
      &lt;ln&gt;${columns[0]}&lt;/ln&gt; 
      &lt;fn&gt;${columns[1]}&lt;/fn&gt;
      &lt;mb&gt;${columns[2]}&lt;/mb&gt;
      &lt;hm&gt;${columns[3]}&lt;/hm&gt;
       &lt;/entry&gt;&quot; &gt;&gt; $tmp_gigabook
  
  done
  # XML footer
  echo '&lt;/list&gt;' &gt;&gt; $tmp_gigabook
  # Remove placeholders / markers
  sed -i 's/±//g' $tmp_gigabook
  
  ## Finalise
  # Copy and adjust
  cp -f $tmp_gigabook $instance/$phonebook
  chown phonesystem:phonesystem $instance/$phonebook
  chmod 600 $instance/$phonebook
  </code></pre>