Conditional IF Question

I trying to get a simple script to see if a directory contains any files in it. I am failing on the conditional IF statement. I am not sure if it because the command I am using is creating the variable as a string or if it is numeric or if I just have the syntax wrong.

#!/usr/bin/ksh
files=$(ls | wc -l)
echo $files
if [[$files -gt 0]];
then
print "There are files";
else
print "There are NO files";
fi
exit
 

Command Output:

1034
./test2.ksh[7]: [[: not found
There are NO files

Any assistance would be appreciated

Thank you

Hi,

You need spaces inside both sides of [[ and ]].

if [[ $files -gt 0 ]];
...
1 Like

Thank you Scott, that fixed it. :b: