我的 shell 脚本中有以下命令,可以在一封电子邮件中发送所有四个 echo 语句
{
echo "Data Successfully loaded into LIP table"
echo "Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`"
echo "Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`"
echo "Error Percentage: $QUERY2"
} | mailx -s "Report for $DATE_YEST_FORMAT1" -r rj@host.com user2@host.com
但是当我看到我的电子邮件时,我得到了下面我不想要的输出 -
Data Successfully loaded into LIP table Total Items Purchased: 3956391
Total Items MissingorMismatch: 975825 Error Percentage: 24.66452380464924
我需要逐行输出如下所示的内容。
Data Successfully loaded into LIP table
Total Items Purchased: 3956391
Total Items MissingorMismatch: 975825
Error Percentage: 24.66452380464924
任何建议为什么会这样?我正在跑步SunOS (Solaris)
。
更新:-
在尝试了给出的建议后Kevin
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';"`
mailx -s "LIP Data Quality Report for $DATE_YEST_FORMAT1" -r rj@host.com rj@host.com uname@host.com <<EOF
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: $(echo $QUERY1 | awk '{print $1}')
Total Items MissingorMismatch: $(echo $QUERY1 | awk '{print $2}')
Error Percentage: $QUERY2
EOF
我在电子邮件中收到的输出 -
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: $(echo 3712928 393455 | awk '{print }')
Total Items MissingorMismatch: $(echo 3712928 393455 | awk '{print }')
Error Percentage: 10.596892802661404
这是不对的..我应该得到这样的输出-
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: 3712928
Total Items MissingorMismatch: 393455
Error Percentage: 10.596892802661404
我在跑步SunOS
bash-3.00$ uname -a
SunOS lvsaishdc3in0001 5.10 Generic_142901-02 i86pc i386 i86pc