Created
April 10, 2016 03:21
-
-
Save antong314/16a89633f7ef67e25a063e3e322781e0 to your computer and use it in GitHub Desktop.
convert pagecount stats to Json messages to be sent to Kafka/MemSQL
This file contains hidden or 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 | |
for f in *.top; do | |
f_notop=${f/.top/} | |
IFS='-' read -r -a array <<< "$f_notop" | |
date=${array[1]} | |
hour=${array[2]} | |
first=0 | |
while read p; do | |
IFS=' ' read -r -a tokens <<< "$p" | |
title=${tokens[1]} | |
count=${tokens[2]} | |
if [ $first = "1" ]; then | |
echo {\""title\"":\""$title\"", \""count\"":$count, \""time\"":\""${date:0:4}-${date:4:2}-${date:6:2} ${hour:0:2}:${hour:2:2}:${hour:4:2}\""} | |
fi | |
first=1 | |
done < $f > $f.json | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment