Skip to content

Instantly share code, notes, and snippets.

@songritk
Created March 24, 2017 08:49
Show Gist options
  • Save songritk/9a04cc72613e58ce211bb3543f70a423 to your computer and use it in GitHub Desktop.
Save songritk/9a04cc72613e58ce211bb3543f70a423 to your computer and use it in GitHub Desktop.
#!/bin/bash
if ! [ $# -eq 1 ];
then
echo "./log-normalize.sh <file>"
exit
fi
file=$1
NAME=`echo "$file" | cut -d'.' -f1`
sed 's/ : Auth: /,Auth,/' $file|sed 's/: \[/,\[/'|sed 's/ (/,/'|sed 's/from client /from client,/'|sed 's/ port /,port,/' |sed 's/ cli /,cli,/'|sed 's/)//' > $NAME-normalize.csv
while read line; do
a=`printf "%s" "$line"|awk -F',' '{print $1}'`
unix=`date -d "$a" +"%s"`
printf "%s,%s\n" "$unix" "$line" >> $NAME-normalize-2.csv
done < $NAME-normalize.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment