I am trying to build a C program that tails a file using tail -f
, but I would like it to do something with the data anytime something is written to the file.
I am a javascript programmer, so this next example probably won't make much sense in the context of the C language, but what I would like to do is this:
#include <stdio.h>
#include <stdlib.h>
int main (){
printf("Tailing file");
system("tail -f read.txt", function(){
// this callback is called everytime new data is outputted from tail
doSomething();
});
exit(0);
}
Is what I'm trying to do possible? Thanks for your help