-
Grep
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
-
You could try
Code:
tail -f filename | grep aaa
-
Ok
It is working . However sometime my application finishes ( stop produce records ) but tail still try to retrieve data from file. I put an fclose ( C programming ) function in my application to close the file but the problem remains . So how I terminate tail ( without use keyboard an Control + c ) ?
Thanks
-
Well if your program wrote to stdout instead of a file, then it would simply be
myprog | grep aaa
Then grep would exit when your program exited.