how to check weather file is blank or not?

Dear All

I want to do following task. Kindly suggest.

In my script every hour one file is genarated. say xyz.txt.

Now if this file contain some data then i want to do task A and if file is blank then i want to do nothing.

Kindly help me to do this.

regards
jaydeep

How blank is blank? Zero bytes or just no alphanumerics?

I would use "egrep" to look for alphabetric characters.

If by "blank" you mean an empty file, you could use the test utility.

[ -s xyz.txt ] && {
     do something
}

there is no alphanumerical. Actually i am generating this file in my script. It will contain some word if my my some database not loaded in system. If all database loded in system is ok then there is no op in that file.

So plz reply.

there is no alphanumerical. Actually i am generating this file in my script. It will contain some word if my my some database not loaded in system. If all database loded in system is ok then there is no op in that file.

So plz reply.

if [ ! -s myfile ]
then
  echo "myfile is empty"
fi