$IMPALA_CONNECTION -q "SELECT * FROM tbls_oldr_30" |
while read DB_NAME TBL_NAME EMPE_USER_ID CREATE_TIME EMPE_SPVR_ID; do
echo -e "Table
Name:$DBS_NAME.$TBL_NAME\nCREATED:$CREATE_TIME\nOWNER:$EMPE_USER_ID\n\nYour
table will be deleted on $new_date " |
mail -E -r [email protected] -s "Your table is over X days old"
[email protected]
done
上面的脚本运行一个查询并将其结果存储在一个变量中。然后它会发送一封电子邮件至[电子邮件受保护]。这可以完美地工作;但是,如果有多个相同的 $EMPE_USER_ID (假设同一用户创建了多个表),它将发送不止一封电子邮件。我想做的是列出所有变量并在一封电子邮件中发送它们。