- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2012-02-16 18:06 编辑
回复 12# cooluncle
1. date
2. awk mktime
3. do it by ourselves
$ cat /tmp/log
Jan 15 04:03:03 xxxx-server-mic cups: cupsd shutdown succeeded
Jan 16 02:03:03 xxxx-server-mic cups: cupsd startup succeeded
Feb 15 15:25:40 xxxx-server-mic kernel: igb: eth0 NIC Link is Down
Feb 16 08:01:01 xxxx-server-mic auditd[4954]: Audit daemon rotating log files
s for start time
e for end of time
t for time by each line
m for month array, and you need add more data for 12 months
$ awk -v s="Jan 15 05:08:00" -v e="Feb 15 20:00:00" 'BEGIN{m["Jan"]="01";m["Feb"]="02";s=m[substr(s,1,3)]s;e=m[substr(e,1,3)]e}{t=m[$1]$1" "$2" "$3;if(s<=t&&t<=e)print}' /tmp/log
Jan 16 02:03:03 xxxx-server-mic cups: cupsd startup succeeded
Feb 15 15:25:40 xxxx-server-mic kernel: igb: eth0 NIC Link is Down
|
|