#!/bin/bash awk ' function month_to_num(month){ if(month=="Jan"){ return(1); }else if(month=="Feb"){ return(2); }else if(month=="Mar"){ return(3); }else if(month=="Apr"){ return(4); }else if(month=="May"){ return(5); }else if(month=="Jun"){ return(6); }else if(month=="Jul"){ return(7); }else if(month=="Aug"){ return(8); }else if(month=="Sep"){ return(9); }else if(month=="Oct"){ return(10); }else if(month=="Nov"){ return(11); }else if(month=="Dec"){ return(12); }else{ return(0); } } { command=sprintf("ls -l %s",$1); name=gensub("[0-9].*","","",$1); command | getline; month=month_to_num($6); day=$7; if(index($8,":")==0){ year=$8; }else{ curmonth=strftime("%m"); if(curmonth<month){ year=strftime("%Y"); }else{ year=strftime("%Y")-1; } } printf("%s|%s-%s-%s|%s\n",name,year,month,day,$9); } ' \ | sort -t\| +0 +1 \ | awk -F\| '{print $3;}'