我有一个巨大的logfile1(Linux),日期格式如下&我想提取过去24小时的数据&用shell脚本写入不同的文件。请帮我完成任务?Shell脚本(提取最近24小时的日志)
----------
03/03/2016 05:40:42 AM QWTRAB1 AMQ7315: Failed to put message to accounting queue. Reason(2053
----------
03/03/2016 05:40:42 AM QWTRAB1 AMQ7315: Failed to put message to accounting queue. Reason(2053
----------
03/03/2016 05:40:46 AM QWTRAB1 AMQ7315: Failed to put message to accounting queue. Reason(2053
----------
03/03/2016 05:40:46 AM QWTRAB1 AMQ7315: Failed to put message to accounting queue. Reason(2053
./test.sh + $的awk'BEGIN {\ n个分割( “一月二月三月四月五月六月七月八月九月十月十一月十二月”,月,““)\ n作为(一= 1; a <= 12; a ++)\ nm [months [a]] = a \ n} \ n {\ n split($ 4,array,“[:/]”); \ n year = array [3] \ n month = sprintf(“%02d”,m [array [2]])\ n \ n print> /apphome/mqm/logs/NewFile"-"year"_"month".txt"\n}'/ apphome/mqm/logs/MQLOGS.OUT.0303160800.txt awk:cmd。行:10:(FILENAME =/apphome/mqm/logs/MQLOGS.OUT.0303160800.txt FNR = 1)致命:除零试图 – Krishna
@Krishna,我已经更新了我的答案。如果您的日志文件中真的有'------'行,您必须先将它们过滤出来... – MaxU