title: How can I count the number of bytes in a binary file in Bash?
body: <p>In Bash, I can count the number of bytes in a text file like this:</p>
  <pre><code>cat textfile.txt | wc -c
  </code></pre>
  <p>However, I can’t <code>cat</code> the contents of a binary file, e.g., a PNG bitmap image file, to standard input.</p>
  <p>How can I count the number of bytes in a bitmap image file?</p>
  <p>I’d rather not count the number of bytes used to store it on disk, as I understand that this can differ between operating systems. Instead, I’m looking for a way to count the number of bytes that would be transferred if the file were served over HTTP (discounting HTTP headers, of course).</p>