Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a shell script that takes backups everyday and emails its execution as successfull or unsuccessfull. Now I want that it send the contents of log file it creates with the mail as well. I have seen how to send file as attachement but I want to send the contents of the file as email message and not the file. Please Help.

Its code is like

#Email Settings
Message_Success="Database Backup generated successfully"
Message_Failure="Problem occured while generating Database Backup please verify"

Subject="Database Backup Status Mail"


#Verify Backup Created
if [ -f "$Path_Mysql_Dump" ]; then
echo "Database Backup Created" >> $Path_Log_File
echo "$Message_Success" | mail -s "$Subject" "$Recipients"
echo "Database Backup not created please verify the process will terminate" >> $Path_Log_File
echo "$Message_Failure" | mail -s "$Subject" "$Recipients"
exit -1
share|improve this question
up vote 5 down vote accepted

Why not

{ echo -e "$Message_Success\n\n" ; cat $Path_Log_file ; } | mail -s "$Subject" "$Recipients"
share|improve this answer
Thanks January :) – Tarun Jul 2 '13 at 12:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.