I am making use of the following code to display the results of my txt file in an email:
mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt
Email Output:
----------Query 1 Count Validation Results--------
Source count is 4
Target count is 3
Source and Target query counts DO NOT match
When I am trying to incorporate the message body, its not working as expected
echo " "########COUNT VALIDATION RESULTS FOR `date +%c`########" | mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt
Actual output:
----------Query 1 Count Validation Results--------
Source count is 4
Target count is 3
Source and Target query counts DO NOT match
########COUNT VALIDATION RESULTS FOR Wed 25 Nov 2015 11:08:37 AM CST########
My desired output is:
########COUNT VALIDATION RESULTS FOR Wed 25 Nov 2015 11:12:29 AM CST########
----------Query 1 Count Validation Results--------
Source count is 4
Target count is 3
Source and Target query counts DO NOT match
We're sorry it is not working too. It you tell us what operating system and shell you're using AND tell us what did happen when you tried Yoda's suggestion, we might be able to help you make it work.
Am I correct in assuming that you're not using a shell that understands Bourne shell syntax?
I must be missing something here. Do you not see any difference between the bash code yoda suggested in post #2 in this thread (which you said you ran in post #3 in this thread):
{
echo "########COUNT VALIDATION RESULTS FOR $(date +%c) ########"
cat Count_Validation_Results_$(date +%m%d%Y).txt
} | mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com
and the commands that you actually ran:
echo "########COUNT VALIDATION RESULTS FOR $(date +%c) ########" cat Count_Validation_Results_$(date +%m%d%Y).txt | mail -s 'Count Validation Test Comparison Results' RONIT@XYZ.COM
Those missing braces, the missing newlines, and the fact that you turned the cat command yoda suggested into operands for your echo command make a HUGE difference.
Please try the code yoda suggested and let us know what happens.