if [ $(stat -c %s $OTDEFERS) -gt 128 ] ; then
echo
echo WARNING: Records have been written to the defers file
STEP_WARNING=1
fi
I'm getting the following error when running this script:
-gt: unary operator expected
I read that putting the variables in double quotes usually does the job but how would it work with a variable that is contained within brackets?
[is by default a command: from the quoting point of view,[ "$var" ...works the same way asecho "$var" ...). – fra-san May 29 '19 at 10:36$(...)) won't make it a fixed string. Single quotes would. See, for reference: What is the difference between “…”, '…', $'…', and $“…” quotes?. Also,stat -c %sreturns a single number (or nothing), thus preventing split+glob of the result of$(...)is likely not necessary. What you need to double-quote is$OTDEFERS→"$OTDEFERS". – fra-san May 29 '19 at 11:07"$OTDEFERS"does not expand to a valid path. Are you getting other error messages (e.g.stat: cannot stat <filename>: No such file or directory)? – fra-san May 29 '19 at 11:18