![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2004
Posts: 8
Rep Power: 0
![]() |
Hi
I have two questions about grep. 1) Is grep support real time analysis ? What I mean ? I have an application that produces records continuously in a file. I try to run grep but grep run faster my application , it find my requested pattern and exits, but my application still produces records. Is there any way for grep to run continuously and produces results while my application running and produce new records ? 2) Can grep show me only the newest pattern that it finds. For example for a file aaa1 aaa2 aaa3 and > grep aaa filename to show me first the aaa1 , then only the aaa2 and then only aaa3 Thanks |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
Grep is not really appropriate for realtime analysis of a logfile, look for 'swatch' for a daemon that handles this.
If I understand your second question you want unique matches. The usual way to do this in the shell is to use sort and uniq. $ grep aaa file | sort | uniq |
|
|
|
|
|
#3 |
|
Programmer
|
In that perticular instance, this would be a little bit more effcient:
$ grep aaa file | sort -u
__________________
<span style='font-size:14pt;line-height:100%'><span style='color:red'>"Political power grows out of the barrel of a gun" - Mao Tse-Tung</span></span> |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
Yeah thats true, I always forget about that -u arg to sort and avoiding an extra process can be very important if the file you grep is huge.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|