syntax for CAT in ksh

Just want to ask if the below code is correct;

if [ {cat out.txt |wc -l} -eq 0 ]; then
echo "No log found from " $data
exit 0
else
cat out.txt
fi

this is to test if the content of out.txt is 0 then message appear that there is no log. Is this correct?

Use the test command with the -s option.

Regards

You don't need to use cat with most commands; they take one or more filenames as arguments, and when they don't (as with tr), you can use redirection. With wc youcan use either, but the result is slightly different. In this case, you want redirection:

wc -l < out.txt

But you don't even need that. To test whether the file has a non-zero length use the -s option to test:

if [ -s out.txt ]; then
   cat out.txt
else
  echo "No log found from " $data
  exit 0
fi

Thank you all. Its working now using -s option.