将bash cat管道格式化为mail命令

时间:2014-10-21 02:39:18

标签: bash formatting sendmail

当我写这个脚本时,它运作得很好。它的作用是区分两个文件 并且如果diff失败,则表明它们在todays文件之间没有变化 和前几天的文件。那些下载过时的过时了。 但是,当我发送电子邮件时,它没有格式化。我喜欢换新线 这样电子邮件就清晰了。但邮件功能不起作用。该文件是 乱翻乱读。

#!/bin/bash
dayofweek=$(/bin/date +%w)
today=$(/bin/date +%Y.%m.%d_)
yesterday=$(/bin/date -d '1 day ago' +%Y.%m.%d_)
destination="/sbclocal/stmevt3/dailymetrics/EQ_PERFORMANCE/"

file1=OPTS_TRIP_TRIP_csv_Oct2014.csv
file2=OPTS_TRIPnon-penny1-20_TRIPnon-penny1-20_Oct2014.csv
file3=OPTS_TRIPnon-penny21-50_TRIPnon-penny21-50_Oct2014.csv
file4=OPTS_TRIPnon-penny51-100_TRIPnon-penny51-100_Oct2014.csv
file5=OPTS_TRIPpenny1-20_TRIPpenny1-20_Oct2014.csv
file6=OPTS_TRIPpenny21-50_TRIPpenny21-50_Oct2014.csv
file7=OPTS_TRIPpenny51-100_TRIPpenny51-100_Oct2014.csv


for i in $file1 $file2 $file3 $file4 $file5 $file6 $file7
do
if diff $destination$today$i $destination$yesterday$i > /dev/null ; then
    printf "$today$i may be stale - please notify production\n" >> /tmp/eq_diffs.$today
sleep 2
else
echo " " > /dev/null
fi
done

#think we might have to do a if file exists
cat /tmp/eq_diffs.$today | mail -s "EQ performance diffs" casper@casper.com

0 个答案:

没有答案