txt files

How can I know if a file contain text or no?

PS: I have to do a script that search for a pattern in text files

You can try to do:

> cat checkfile 
#! /bin/bash

if [ -f sample.txt ]
   then
   echo "ordinary file"
fi
if [ -s sample.txt ]
   then 
   echo "non-zero length file"
fi