Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email based on file size

Status
Not open for further replies.

sam93

Programmer
Jul 19, 2002
65
CA
Hi,

I'm new to Unix environment, so I need help with this probably a simple task. I'm trying to send an email, based on the size (or existance) of a file, i.e., if the file is empty (or it dos not exist) on the given location, I don't need to send the email. However, if the file exists and is not empty, I have to send email.

How can I check if the file exists on the specified location and it's not empty.

Thanks for the help.
 
Try something like this:
Code:
if [ -s /path/to/file ]; then
  echo "OK"
else
  echo "Empty or non-existent"
file
FYI: man test

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top