A couple of syntactic issues.
- The variable definitions in Bash do not take spaces. It should have been
MAXSIZE=500000
, without spaces. - The way comparison operation is done is incorrect. Instead of
if [ (( $FILESIZE > MAXSIZE)) ];
, you could very well use Bash’s own arithmetic operator alone and skip the[
operator to justif (( FILESIZE > MAXSIZE)); then
If you are worried about syntax issues in your script, use ShellCheck to syntax check your scripts and fix the errors as seen from it.
As a general coding practice, use lowercase user-defined variables in Bash to avoid confusing them with the special environment variables which are interpreted for different purposes by the shell (e.g., $HOME
and $SHELL
).