Sorting records in unix
On Unix: I have a text file that has records that I need to sort in ascending order of date and time. I have looked at the sort command and couldn't get it to work for me. Could someone please help me with this? Or point me in the right direction?
{
DateAndTime : "2010-08-27-11.42.43.082-0400",
TestString:"12开发者_开发知识库3",
TestData : {
{ field0 : "1234" },
{ field1 : "5678" }
}
}
{
DateAndTime : "2010-08-28-11.43.43.082-0400",
TestString:"123",
TestData : {
{ field0 : "1234" },
{ field1 : "5678" }
}
}
Reading file line by line using awk or read will help.
cat test | while read field1 $field2 ; do sorting with field1 and prev_field1; prev_field1=field1 ; done
精彩评论