Skip to content

Instantly share code, notes, and snippets.

@siwells
Created October 23, 2013 16:31
Show Gist options
  • Save siwells/7121958 to your computer and use it in GitHub Desktop.
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.
#!/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