Last active
July 7, 2017 18:30
-
-
Save nehaljwani/5942908 to your computer and use it in GitHub Desktop.
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/sh | |
#+Author: Nehal J Wani | |
#To Convert logformat squid %tl %6tr %>a %Ss/%03>Hs %<st %rm %ru %un %Sh/%<A %mt to Default | |
cat $1 | awk -v FS='/' '{ printf "06/%s/",$1; printf "%.4s %s\n",$3, substr($3,6,9)}' > STAMP | |
cat STAMP | uniq -c | awk '{{ print $1 > "COUNT"} {print $2,$3 > "STAMP_1"}}' | |
rm -f STAMP | |
while read line ; do echo `date -d "$line" "+%s"`".000" ; done < STAMP_1 > TIMESTAMP | |
rm -f STAMP_1 | |
python -c " | |
f1=open('COUNT').read().split(); | |
f2=open('TIMESTAMP').read().split(); | |
f3=open('ROW1','w'); | |
size=len(f1); | |
for i in range(size): f3.write((f2[i]+'\n')*int(f1[i])); | |
" | |
rm -f TIMESTAMP COUNT | |
cat $1 | awk '{for(i=3;i<NF;i++) printf "%s ",$i; printf "\n"}' > REST | |
paste -d' ' ROW1 REST > ${1}_FINAL | |
rm -f ROW1 REST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
genius , greetings from argentina