title: Portable way to get file size (in bytes) in the shell
body: <p>On Linux, I use <code>stat --format=&quot;%s&quot; FILE</code>, but the <a href="https://en.wikipedia.org/wiki/Solaris_%28operating_system%29" rel="noreferrer">Solaris</a> machine I have access to doesn't have the <code>stat</code> command. What should I use then?</p>
  <p>I'm writing Bash scripts and can't really install any new software on the system.</p>
  <p>I've considered already using:</p>
  <pre><code>perl -e '@x=stat(shift);print $x[7]' FILE
  </code></pre>
  <p>or even:</p>
  <pre><code>ls -nl FILE | awk '{print $5}'
  </code></pre>
  <p>But neither of these looks sensible - running <a href="https://en.wikipedia.org/wiki/Perl" rel="noreferrer">Perl</a> just to get file size? Or running two programs to do the same?</p>