通过shell命令实现排序

使用shell命令分析文件内容,获取最新的日期链接。

cat test.html|grep -Eo  '[0-9]{2,5}-20[0-9]{2}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}'  |uniq|awk 'BEGIN{now=systime(); min=0; ctime=0; count=0;} {otime=$0; print "otime=" otime; gsub(/[-_]/," "); rtime=$0; rtime=substr(rtime, index(rtime," ")+1); print "rtime=" rtime; rtime=mktime(rtime); print "rtime=" rtime; interval=now-rtime; if(count==0) {min=interval } if(min > interval) {min=interval;ctime=otime;print interval}; count++;} END {print ctime}'

猜你喜欢

转载自liujie5354.iteye.com/blog/2209094