| | 91 | |
| | 92 | == convert epoch time to human on Log file == |
| | 93 | |
| | 94 | ref [https://unix.stackexchange.com/questions/623046/convert-replace-time-from-epoch-milliseconds-to-human-readable-date-in-logfiles here] |
| | 95 | |
| | 96 | Example: file.log |
| | 97 | {{{ |
| | 98 | 1522693524403 entity1,sometext |
| | 99 | 1522693541466 entity2,sometext |
| | 100 | 1522693547273 entity1,sometext |
| | 101 | }}} |
| | 102 | |
| | 103 | Just use |
| | 104 | |
| | 105 | {{{ |
| | 106 | $ awk '{$1 = strftime("%F %T", substr($1,1,10))} 1' file.log |
| | 107 | 2018-04-02 21:25:24 entity1,sometext |
| | 108 | 2018-04-02 21:25:41 entity2,sometext |
| | 109 | 2018-04-02 21:25:47 entity1,sometext |
| | 110 | }}} |
| | 111 | |
| | 112 | With milliseconds |
| | 113 | |
| | 114 | {{{ |
| | 115 | $ awk '{$1 = strftime("%F %T", substr($1,1,10)) "." substr($1,11)} 1' file.log |
| | 116 | 2018-04-02 21:25:24.403 entity1,sometext |
| | 117 | 2018-04-02 21:25:41.466 entity2,sometext |
| | 118 | 2018-04-02 21:25:47.273 entity1,sometext |
| | 119 | }}} |