title: How can I check the size of a file using Bash?
body: <p>I've got a script that checks for 0-size, but I thought there must be an easier way to check for file sizes instead.  I.e. <code>file.txt</code> is normally 100 kB; how can I make a script check if it is less than 90 kB (including 0), and make it <a href="https://en.wikipedia.org/wiki/Wget" rel="nofollow noreferrer">Wget</a> a new copy because the file is corrupt in this case?</p>
  <p>What I'm currently using...</p>
  <pre><code>if [ -n file.txt ]
  then
    echo &quot;everything is good&quot;
  else
    mail -s &quot;file.txt size is zero, please fix. &quot; myemail@gmail.com &lt; /dev/null
    # Grab wget as a fallback
    wget -c https://www.server.org/file.txt -P /root/tmp --output-document=/root/tmp/file.txt
    mv -f /root/tmp/file.txt /var/www/file.txt
  fi
  </code></pre>