Display log file with timestamp in human-readable format

By default, some logs (like squid logs) will be recorded with unix timestamp, stored as <unixtimestamp>.<centisecond> which are hard to read for analysis.

You would have for example this kind of logs:

1702397611.273  14010 192.168.1.2 TCP_MISS_ABORTED/000 0 GET http://xx.yyy.zz/ - HIER_DIRECT/0.0.0.0 -
1702397866.155   1092 192.168.1.2 TCP_TUNNEL_ABORTED/200 5478 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -
1702397866.161   1349 192.168.1.2 TCP_TUNNEL_ABORTED/200 4589 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -
1702398066.598  34006 192.168.1.2 TCP_TUNNEL/200 7336 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -
1702398133.589  63009 192.168.1.2 TCP_TUNNEL/200 4989 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -

In order to display them in human readable format, you can just use that simple command:

cat access.log | perl -p -e 's/^([0-9\.]*)/"[".localtime($1)."]"/e'

You will then have such result:

[Tue Dec 12 17:13:31 2023]  14010 192.168.1.2 TCP_MISS_ABORTED/000 0 GET http://xx.yyy.zz/ - HIER_DIRECT/0.0.0.0 -
[Tue Dec 12 17:17:46 2023]   1092 192.168.1.2 TCP_TUNNEL_ABORTED/200 5478 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -
[Tue Dec 12 17:17:46 2023]   1349 192.168.1.2 TCP_TUNNEL_ABORTED/200 4589 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -
[Tue Dec 12 17:21:06 2023]  34006 192.168.1.2 TCP_TUNNEL/200 7336 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -
[Tue Dec 12 17:22:13 2023]  63009 192.168.1.2 TCP_TUNNEL/200 4989 CONNECT xx.yyy.zz:443 - HIER_DIRECT/0.0.0.0 -