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
> grep aaa filename
to show me first the aaa1 , then only the aaa2 and then only aaa3
You could try
tail -f filename | grep aaa
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 ) ?
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.