Created
May 10, 2018 13:27
-
-
Save yerstd/235b602353ccfe44ea93e4b1d64116d2 to your computer and use it in GitHub Desktop.
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 | |
logfile=big-log.txt | |
keyStr="" | |
valStr="" | |
awk -F{ '{print $2}' $logfile | awk -F, '{ | |
for (i=1;i<=5;i++){ | |
print $i; | |
} | |
}' | awk -F: '{print $1,$2,NR}' | while read key val n;do | |
#echo "$n : $key => $val" | |
if [ `expr $n % 5` == 1 ];then | |
keyStr=$key | |
valStr=$val | |
else | |
keyStr="$keyStr,$key" | |
valStr="$valStr,$val" | |
echo $keyStr | |
echo $valStr | |
fi | |
if [ `expr $n % 5` -eq 0 ] && [ $n > 0 ];then | |
printf "insert into game_answer_history (%s) values (%s)\n" $keyStr $valStr >> /tmp/test.sql | |
keyStr="" | |
valStr="" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment