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
  • Did the other script I wrote for you work? Jun 14, 2011 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, 2011 at 10:11
  • @paulmorriss yep I accept that for you
    – Grimlockz
    Jun 15, 2011 at 12:58

1 Answer 1


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.

  • @paulmorriss the changes just adds a blank line underneath the users email in the text file
    – Grimlockz
    Jun 15, 2011 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. Jun 15, 2011 at 14:09
  • @paulmorriss just done the grep on its on and its a blank text file
    – Grimlockz
    Jun 15, 2011 at 14:14
  • Are the counts after the username and the colon working? Jun 15, 2011 at 14:15
  • @paulmorriss using a new blank script so no counts just that grep
    – Grimlockz
    Jun 15, 2011 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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