title: Linux Bash Scripting: Obtain the total size of 'png' and 'gif' files in a given Directory then compare the size
body: <p>I'm new to Linux bash scripting in general and apologies in advance if this question is stupid.</p>
  <p>Basically, I have this scenario where I need to obtain the total size of 'png' and 'jpeg' files in the same directory then afterwards compare this total size with a fixed value of (200kb). The problem im having is that I'm not sure how to obtain the total file size in the first place. Any help would be well appreciated..</p>
  <p>What I've tried:
  (find the total file sizes of both jpeg and png files then save it inside variables</p>
  <pre><code>jpegsize = $({ find &lt;DIR&gt; -type f -name &quot;*.jpg&quot; -printf &quot;%s+&quot;; echo 0; } | bc)
  
  pngsize = $({ find &lt;DIR&gt; -type f -name &quot;*.png&quot; -printf &quot;%s+&quot;; echo 0; } | bc)
  
  totalsize = $jpegsize + $pngsize
  
  if (($totalsize &lt;= 200000))
  
  then 
  
         echo &quot;total image size is small&quot;
  else
  
  then
  
         echo &quot;total image size is NOT small&quot;
  fi
  </code></pre>