Hi, I have a log file which has the following format ( its nominally CSV )
John@gmail.com,1268727836,lots,more,fields
I would like to change the second field to a date format the DB I am going to load this into will understand rather than Epoch time i.e.
John@gmail.com,2010/03/16 08:23:56,lots,more,fields
and if possible also add a field at the end of the line containing the original file name i.e.
John@gmail.com,2010/03/16 08:23:56,lots,more,fields,logfile1.log
Whats an efficient way to do this in perl ( there are lots of files with millions of lines ) ? I have found I can generate an individual date which would work with the following code
perl -MPOSIX -le 'print strftime "%F %T", localtime 1268727836'
Its just the looping through the file and running this to sub field 2 in every line that I cant seem to crack - Any help greatly appreciated.
In reply to Convert Epoch times in Logfile by stevbutt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |