需求是把所有的日志中邮箱获取出来,根据指定关键字过滤,邮箱的格式是\txxx@xxx\t的格式,日志的存放是按照日期作为目录
#!/bin/bash logBasePath="/data1/mailLog/app/kafka/"; monthYearDay=`date -d "1 day ago" +"%Y-%m-%d"`; #安卓每日邮箱个数 logPath="${logBasePath}${monthYearDay}/api-mail-sina-com-cn.log"; tmpFile="/tmp/${monthYearDay}.android.email.log"; echo "start android email..."; cat $logPath|grep '2026078627'|grep -oP '\\t[^\\]+@.*?\\t'|sed 's/\\t//g'|uniq|sort -u > $tmpFile; echo $tmpFile; androidEmailNum=`wc -l ${tmpFile}`; #IOS每日邮箱个数 tmpFile="/tmp/${monthYearDay}.ios.email.log"; echo "start ios email..."; cat $logPath|grep '2503566089'|grep -oP '\\t[^\\]+@.*?\\t'|sed 's/\\t//g'|uniq|sort -u > $tmpFile; echo $tmpFile; iosEmailNum=`wc -l ${tmpFile}`; #安卓每日设备数 tmpFile="/tmp/${monthYearDay}.android.device.log"; echo "start android device..."; cat $logPath|grep '2026078627'|grep -oP "device_id=[^&\"]+"|uniq|sort -u > $tmpFile; echo $tmpFile; androidDeviceNum=`wc -l ${tmpFile}`; #ios每日设备数 tmpFile="/tmp/${monthYearDay}.ios.device.log"; echo "start ios device..."; cat $logPath|grep '2503566089'|grep -oP "device_id=[^&\"]+"|uniq|sort -u > $tmpFile; echo $tmpFile; iosDeviceNum=`wc -l ${tmpFile}`; mailContent=" Android每日邮箱账号活跃数:<br/><br/>${androidEmailNum}<br/><br/>IOS每日邮箱账号活跃数:<br/><br/>${iosEmailNum}<br/><br/> Android每日设备活跃数:<br/><br/>${androidDeviceNum}<br/><br/>IOS每日设备活跃数:<br/><br/>${iosDeviceNum} " echo $mailContent; php /usr/local/sinamail/tools/new/sumMobileDevice/sumMobileDevice.php "${mailContent}"
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:[Linux] 获取出日志中的邮箱shell - Python技术站