title: Get total size of a list of files in UNIX
body: <p>I want to run a <code>find</code> command that will find a certain list of files and then iterate through that list of files to run some operations. I also want to find the total size of all the files in that list.</p>
  
  <p>I'd like to make the list of files FIRST, then do the other operations. Is there an easy way I can report just the total size of all the files in the list?</p>
  
  <p>In essence I am trying to find a one-liner for the 'total_size' variable in the code snippet below:</p>
  
  <pre><code>#!/bin/bash
  loc_to_look='/foo/bar/location'
  
  file_list=$(find $loc_to_look -type f -name "*.dat" -size +100M)
  
  total_size=???
  
  echo 'total size of all files is: '$total_size
  
  for file in $file_list; do
           # do a bunch of operations
  done
  </code></pre>