Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8357719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:34:17+00:00 2026-06-09T10:34:17+00:00

Below is my shell script that is working fine. #!/bin/bash DATE_YEST_FORMAT2=`perl -e ‘use POSIX

  • 0

Below is my shell script that is working fine.

#!/bin/bash

DATE_YEST_FORMAT2=`perl -e 'use POSIX qw(strftime); print strftime "%Y%m%d",localtime(time()- 3600*96);'`
echo $DATE_YEST_FORMAT2

QUERY1=`hive -e "
set mapred.job.queue.name=hdmi-technology;
SELECT SUM(total_items_purchased), SUM(total_items_missingormismatch) from lip_data_quality where dt='$DATE_YEST_FORMAT2';`

QUERY2=`hive -e "
set mapred.job.queue.name=hdmi-technology;
SELECT 100 * SUM(total_items_missingormismatch*1.0) / SUM(total_items_purchased) FROM lip_data_quality where dt='$DATE_YEST_FORMAT2';"`

echo "Total items purchased: `echo $QUERY1 | awk '{print $1}'`"
echo "Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`"
echo "Error Percentage: $QUERY2"

I am running the above shell script like this below-

sh -x test.sh

Problem Statement:-

From the above shell script, I am getting below three things from the last three echo statements-

Total items purchased
Total Items MissingorMismatch
Error Percentage

I need to send all these above three things in an email to our email group we have DL-host@company.com by using that shell script above or suppose if I have 10 email list to which I need to send email with the same contents and subjects, then I think, I can store all these 10 emails list in some variable and just read it from there and keep on sending, right?. Is this possible to do it? I was thinking email structure like this below, just making very simple.

Subject

Test Data

Mail Body

Total items purchased:-    Some Number
Total Items MissingorMismatch:-   Some Number
Error Percentage:-   Some Number

Any thoughts will be appreciated.

Update, After trying larsks suggestions, I am getting only last echo statement in an email meaning only the error percentage one, not all three in a single email:-

#!/bin/bash

DATE_YEST_FORMAT2=`perl -e 'use POSIX qw(strftime); print strftime "%Y%m%d",localtime(time()- 3600*96);'`
echo $DATE_YEST_FORMAT2

QUERY1=`hive -e "
set mapred.job.queue.name=hdmi-technology;
SELECT SUM(total_items_purchased), SUM(total_items_missingormismatch) from lip_data_quality where dt='$DATE_YEST_FORMAT2';`

QUERY2=`hive -e "
set mapred.job.queue.name=hdmi-technology;
SELECT 100 * SUM(total_items_missingormismatch*1.0) / SUM(total_items_purchased) FROM lip_data_quality where dt='$DATE_YEST_FORMAT2';"`

echo "Total items purchased: `echo $QUERY1 | awk '{print $1}'`"
echo "Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`"
echo "Error Percentage: $QUERY2" | mail -s "Test Data" rj@host.com
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:34:18+00:00Added an answer on June 9, 2026 at 10:34 am

    You typically use the /bin/mail program to send email from a shell script. You provide a subject and recipients on the command line and the message body on stdin. For example, inside your script you could do something like this:

    {
    echo "Total items purchased: `echo $QUERY1 | awk '{print $1}'`"
    echo "Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`"
    echo "Error Percentage: $QUERY2"
    } | mail -s "Test Data" DL-host@company.com
    

    You can also pipe the output of an existing script into mail (if you don’t want to modify the script, or if you only want to send mail somtimes):

    <your script> | mail -s "Test Data" DL-host@company.com
    

    You can specify multiple recipients on the command line, so:

    ... | mail -s "Test Data" address1@company.com address2@company.com
    

    and so forth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am testing with the shell script below: #!/bin/ksh -x instance=`echo $1 | cut
I have a Unix shell script (bash) that sources some environment variables and then
I have a bash shell script that loops through all child directories (but not
Below is my shell script that I am trying to execute using PLINK on
Following the shell script that I am executing #!/bin/sh echo Enter [y/n] : read
I have the below line in the unix shell script. I want to exclude
I've written a simple shell script that finds large files, mostly to save myself
I am using the below code for replacing a string inside a shell script.
I have this shell script #!/bin/sh ############################################################# # Example startup script for the SecureTrading
I was working on a little script that would do some logging for me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.