Mobile app version of vmapp.org
Login or Join
Frith620

: Grep directory name Need a script to grep within a directory for folders named by emails (so looking for the @) to then search the apache logs to see if the email address grep'ed has accessed

@Frith620

Posted in: #Apache #ApacheLogFiles #Linux #LookingForAScript

Need a script to grep within a directory for folders named by emails (so looking for the @ ) to then search the apache logs to see if the email address grep'ed has accessed the website today.

Then after this I need to look at the user-agents detail to see what browser they are using

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Frith620

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gretchen104

for i in `ls emaildir/*@*`
do
grep $i logfile | grep '['`date +%d/%b/%Y` | awk -F" '{print }'
done


Where emaildir is the directory of files containing email addresses and logfile is the apache logfile.

What it's doing is this:


getting each file in the email directory with an @ in the filename
searching the log file for lines containing that filename
then searching those lines for today's date in the format used by logfiles
then splitting the line at quote marks and printing the sixth part, which is the browser string

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme