我编写了一个脚本来获取用户的浏览器版本,但我需要清理输出。该脚本的作用是查看@和IE8的apache日志,然后通过电子邮件向我发送信息。我的问题是输出,因为当grep找到一个电子邮件地址时,IE8它给了我完整的输出 - 即/page/code/user@foobar.com/home.php而输出我看的只是电子邮件地址,并且每天只记录一次此信息:
示例:
user @ foobar IE8
由于
#!/bin/bash
#Setting date and time (x and y and z aren't being used at the moment)
x="$(date +'%d/%b/%Y')"
y="$(date +'%T')"
z="$(date +'%T' | awk 'BEGIN { FS =":"} ; {print $1}')"
#Human readable for email title
emaildate=$(date +"%d%b%Y--Hour--%H")
#Setting date and time for grep and filename
beta="$(date +'%d/%b/%Y:%H')"
sigma="$(date +'%d-%b-%Y-%H')"
#CurrentAccess logs
log='/var/logs/access.log'
#Set saved log location
newlogs=/home/user/Scripts/browser/logs
#Prefrom the grep for the current day
grep @ $log | grep $beta | awk 'BEGIN { FS = " " } ; { print $7 }' | sort -u >> $newlogs/broswerusage"$sigma".txt
mail -s "IE8 usage for $emaildate" user@exmaple.com < $newlogs/broswernusage"$sigma".txt