title: Sum of file sizes with awk on a list of files
body: <p>I have a list of files and want to sum over their file sizes.
  So, I created a (global) variable as counter and are trying to loop over that list, get the file size with ls and cut&amp;add it with </p>
  
  <pre><code>export COUNTER=1
  for x in $(cat ./myfiles.lst); do ls -all $x | awk '{COUNTER+=$5}'; done
  </code></pre>
  
  <p>However, my counter is empty?</p>
  
  <pre><code>&gt; echo $COUNTER
  &gt; 1
  </code></pre>
  
  <p>Does someone has an idea for my, what I am missing here?</p>
  
  <p>Cheers and thanks,
    Thomas</p>
  
  <hr>
  
  <p>OK, I found a way piping the result from the awk pipe into a variable
  (which is probably not elegant but working ;) )</p>
  
  <pre><code>for x in $(cat ./myfiles.lst); do a=$(ls -all $x |awk '{print $5}'); COUNTER=$(($COUNTER+$a)) ; done
  
  &gt; echo $COUNTER
  &gt; 4793061514
  </code></pre>