Perl script to copy logs with timestamps for each hour and paste into a different file

advertisements

First of all, I'm very new to programming and so would need your help in writing a perl script to do the following on windows.

I have a big log file with timestamp (1gb) and its difficult to read the logs as it takes a lot of time to open. so my requirement is to copy the logs from the bigger log file for the last one hour and paste it to another file and then copy the next 1 hr of data to different file(so we will have 24 files for a day). The next day the data in these files needs to be over written or delete & create a new file.

Sample log :

09092016-00:02:00,..................
09092016-00:02:08,..................
09092016-00:02:15,..................
09092016-00:02:18,..................

Please help me with this and thanks for your help in advance.

Thanks,


A simpler solution would be to use the split command to split the files into manageable sizes.

split -l 1000 logfile

Will split your logfile into smaller files of 1000 lines each. You can then just use grep to find the files that contain the day you need.

grep 09092016 logfile*