theNbomr is talking about the old way to embed commands using ` backticks instead of $(), not changing the single quotes, which in this case protect the expression that's being passed to awk.
Code:
filesize=`awk 'END {print NR}' $somefile`
This shouldn't be your problem though, unless your version of bash is incredibly old (run 'bash --version' to find out).
You should probably also use double-quotes around the string when setting variables, to ensure that the output is seen as a single string and to escape any bad substitutions. Not that that's necessarily the problem here, however.
Code:
filesize="$(awk 'END {print NR}' $somefile)"
But if all you want to do is determine if the file is empty, there are already
tests available for that.
Code:
if [[ -f "$1" && ! -s "$1" ]]; then
echo "Regular file $1 is an empty file."
elif [[ -f "$1" && -s "$1" ]]; then
echo "Regular file $1 is not empty."
else
echo "$1 is not a regular file."
fi
Edit: I see you figured the backquote thing out on your own.
I don't know why the original code isn't working for you. It works for me with no problem. Is there anything unusual about your setup that we should know about?