Created
October 23, 2013 16:31
-
-
Save siwells/7121958 to your computer and use it in GitHub Desktop.
Short script to process SUPERHUB log files to count the total number of access and the unique number of access to the application between the supplied dates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
currentDateTs=$(date -j -f "%Y-%m-%d" $1 "+%s") | |
endDateTs=$(date -j -f "%Y-%m-%d" $2 "+%s") | |
offset=86400 | |
while [ "$currentDateTs" -le "$endDateTs" ] | |
do | |
date=$(date -j -f "%s" $currentDateTs "+%Y-%m-%d") | |
searchstring="INFO | $date" | |
accesses=`cat sh.txt | grep "$searchstring" | cut -f 6 -d \| | wc -w` | |
unique=`cat sh.txt | grep "$searchstring" | cut -f 6 -d \| | uniq | wc -w` | |
echo $date","$accesses","$unique | |
currentDateTs=$(($currentDateTs+$offset)) | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment