Hi All,

I need your valuable suggestion as how to sort the log files based on timestamp. Below is the sample log content.

string May 28 22:07:48 2015 Log data
string May 28 22:07:48 2015 Log data
string May 28 22:07:48 2015 Log data

I would like to sort based on "May 28 22:07:48 2015". It has both numeric and characters. so What is the way to achive dresired output.

Your help will be much appreciated.

Thanks,
Manju

The best way is to configure the program that creates the file to use the ISO standard date format: YYYY-MM-DDTHH:MM:SS

Then the sort command will do the job.

Hi cfajohnson,

Thanks for the suggestion, Could you let me know if this is fine.YYYY-MM-DDTHH:MM:SS ==> 2015-06-01 10:20:30

Thanks,
Manju

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.