C
C
cru5ader2017-03-31 08:12:14
linux
cru5ader, 2017-03-31 08:12:14

Parsing nginx log?

Good morning, please help me figure out the log parsing:
28 Mar 2017 00:01:23 0.017
28 Mar 2017 00:01:23 0.007
...................... ................................
I'm interested in converting time to epoch time without losing value after the date
, let 's say
1490648483:0.017
1490648483 :0.007

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neol, 2017-03-31
@cru5ader

STRING='28 Mar 2017 00:01:23 0.017'
DATETIME=`echo $STRING | awk '{print $1,$2,$3,$4}'`
TIME=`date -d "$DATETIME" "+%s"`
echo $STRING | sed "s/$DATETIME /$TIME:/g"

Output:
1490648483:0.017

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question