mycustomfile.log
Linux에서 30분마다 파일 내용을 읽어야 합니다.
나는 노력했다egrep "06:00| 06:30"
하지만 원하는 결과를 얻지 못했습니다.
06:00:24 rdy->395 bsy->205 ka->29
06:30:27 rdy->339 bsy->261 ka->40
07:00:30 rdy->259 bsy->341 ka->80
**07:06:30 rdy->282 bsy->318 ka->73**
**07:07:30 rdy->234 bsy->366 ka->80**
07:30:32 rdy->455 bsy->445 ka->85
위에 강조 표시된 결과는 **
올바른 항목입니다. 이들을 제외하고 30분마다 결과를 확인해야 합니다.
내가 무엇을 놓치고 있나요?
아래 업데이트는 내 입력 파일입니다.
[Thu Mar 30 00:00:37 2017] [notice] mpmstats: rdy 26 bsy 49 rd 45 wr 1 ka 3 log 0 dns 0 cls 0
[Thu Mar 30 00:10:38 2017] [notice] mpmstats: rdy 46 bsy 54 rd 53 wr 0 ka 1 log 0 dns 0 cls 0
[Thu Mar 30 00:20:39 2017] [notice] mpmstats: rdy 55 bsy 45 rd 45 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 00:30:39 2017] [notice] mpmstats: rdy 48 bsy 52 rd 51 wr 0 ka 1 log 0 dns 0 cls 0
[Thu Mar 30 00:40:40 2017] [notice] mpmstats: rdy 74 bsy 26 rd 23 wr 0 ka 1 log 0 dns 0 cls 2
[Thu Mar 30 00:50:41 2017] [notice] mpmstats: rdy 44 bsy 14 rd 12 wr 0 ka 2 log 0 dns 0 cls 0
[Thu Mar 30 01:00:41 2017] [notice] mpmstats: rdy 41 bsy 9 rd 9 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 01:10:42 2017] [notice] mpmstats: rdy 39 bsy 11 rd 5 wr 0 ka 6 log 0 dns 0 cls 0
[Thu Mar 30 01:20:42 2017] [notice] mpmstats: rdy 45 bsy 5 rd 5 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 01:30:43 2017] [notice] mpmstats: rdy 31 bsy 19 rd 18 wr 0 ka 1 log 0 dns 0 cls 0
[Thu Mar 30 01:40:44 2017] [notice] mpmstats: rdy 59 bsy 16 rd 16 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 01:50:44 2017] [notice] mpmstats: rdy 62 bsy 13 rd 13 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 02:00:45 2017] [notice] mpmstats: rdy 70 bsy 5 rd 5 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 02:10:45 2017] [notice] mpmstats: rdy 69 bsy 6 rd 5 wr 0 ka 1 log 0 dns 0 cls 0
[Thu Mar 30 02:20:46 2017] [notice] mpmstats: rdy 57 bsy 18 rd 18 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 02:30:47 2017] [notice] mpmstats: rdy 69 bsy 6 rd 6 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 02:40:47 2017] [notice] mpmstats: rdy 69 bsy 6 rd 6 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 02:50:48 2017] [notice] mpmstats: rdy 73 bsy 2 rd 2 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 03:30:50 2017] [notice] mpmstats: rdy 72 bsy 3 rd 3 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 03:40:51 2017] [notice] mpmstats: rdy 72 bsy 3 rd 3 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 03:50:52 2017] [notice] mpmstats: rdy 74 bsy 1 rd 1 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 04:00:52 2017] [notice] mpmstats: rdy 74 bsy 1 rd 1 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 04:10:53 2017] [notice] mpmstats: rdy 73 bsy 2 rd 2 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 04:20:54 2017] [notice] mpmstats: rdy 64 bsy 11 rd 11 wr 0 ka 0 log 0 dns 0 cls 0
[Thu Mar 30 04:30:54 2017] [notice] mpmstats: rdy 71 bsy 4 rd 4 wr 0 ka 0 log 0 dns 0 cls 0
답변1
사용중인 grep 패턴은 시간:분 대신 분:초를 제공합니다.
다음 grep이 더 정확합니다.
그 뒤에 몇 초가 있음을 나타내기 위해 분 뒤에 ":"를 추가했습니다.
egrep "06:00:|06:30:"
또는 보다 일반적인 grep:
egrep ":00:|:30:"