http://murugesan.webnode.c
h
Command to sort by date in the files containing variable length of lines:
awk '{
currentLine=""
for(i=1;i<=NF;i++)
{
if(i==NF)
{
currentLine=currentLine"be
}
else
{
currentLine=currentLine" "$i
}
}
print currentLine
}' murugesandins.txt | sort -t'/' -k2n -k3n -k4n | sed 's/beforeLastField\// /g;'
Main Topics
Browse All Topics





by: oocytePosted on 2009-10-13 at 14:25:16ID: 25564934
Assume you have the dates in a.txt, you can use the following to sort through the dates. I'll sort by Year, then Month, then Day. I ran the above on Solaris and it give the following:
557 10/13/2009
961 9/11/2009
032 8/19/2009
657 8/19/2009
633 7/22/2009
238 6/23/2009
483 6/23/2009
Select allOpen in new window