Learning Academy

The Cure of Ignorance is to Question. MUHAMMAD (PBUH)

CentOS

How to convert Squid unixtime logs in human-readable format?

squid-shade1If you’re looking at squid access.log, you’ll find the first column of it is the time, for example:
 

1310313302.640 829 58.215.75.51 TCP_MISS/200 104 CONNECT smtp.126.com:25 – DIRECT/123.125.50.112 –
 

1310313303.484 1845 58.215.75.51 TCP_MISS/200 104 CONNECT smtp.126.com:25 – DIRECT/123.125.50.111 –

This is not very human readable.

To convert Squid unixtime logs in human-readable format, one can use following command:

 

perl -p -e ‘s/^([0-9]*)/”[“.localtime($1).”]”/e’ > converted.log

 

 

Muhammad Shaukat

Content Developer at LearnAcad.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest