Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Been trying for a while to get this script fully working I think I'm nearly there.

Ok so I basically need the script to show 3 things, email address - Browser type - Time logged in.

while read MAIL;
grep -f $EMAILS /var/log/apache2/ssl_access.log>>/home/user/test.txt
done < $EMAILS

I need some way of first using the todays date in here so it only searches the apache logs for that data. I was thinking about using the linux date +"[%d/%b/%Y" command in the script as this will match the correct date formate.

The other aspect is that I only need the output to show the user's email address | Browser type and date from apache nothing else.

HELP please


Managed to play around with the script and got it to this stage where it works fine I just need to work out how to add browser data into the text file?

x=$(date +"%d/%b/%Y")
y=$(date +"%d%b%Y")
while read filename
        if COUNT=$(grep $filename /var/log/apache2/ssl_access.log |grep -c $x) 
        echo $filename:$COUNT>>/home/user/logs/usage"$y".txt  
done < emaillist.txt
share|improve this question
Did the other script I wrote for you work? – paulmorriss Jun 14 '11 at 9:35
@paulmorriss It I've managed to get the above script working as well now but just can't get the browser data into the script – Grimlockz Jun 15 '11 at 10:11
Do you want to accept my other answer then? – paulmorriss Jun 15 '11 at 11:52
@paulmorriss yep I accept that for you – Grimlockz Jun 15 '11 at 12:58
up vote 1 down vote accepted

If you put

grep $filename /var/log/apache2/ssl_access.log |grep $x | awk -F\" '{print $6}' | sort -u >> /home/user/logs/usage"$y".txt 

before the fi that should put the browser information into the text file (and remove duplicate lines where they are the same) after the line with the count on it.

share|improve this answer
@paulmorriss the changes just adds a blank line underneath the users email in the text file – Grimlockz Jun 15 '11 at 14:01
Do you want to try each bit in turn so the first grep, then the first and second grep and see what comes out. – paulmorriss Jun 15 '11 at 14:09
@paulmorriss just done the grep on its on and its a blank text file – Grimlockz Jun 15 '11 at 14:14
Are the counts after the username and the colon working? – paulmorriss Jun 15 '11 at 14:15
@paulmorriss using a new blank script so no counts just that grep – Grimlockz Jun 15 '11 at 14:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.