I have an OSX GUI application which I can't change - it writes new CVS lines to a log file when it completes a job. I'd like to work with these new lines, but they are constantly being added.
Is there a way to redirect the application's output directly into a script where I can then process the new lines as it generates them? Reading the file every X seconds to pick up changes isn't desirable, and while I could use
launchd to detect changes to the file and process them that way - I'm looking for something a bit more elegant. Any ideas (with examples - I'm learning) would be much appreciated.
I'm not sure it's the best approach, but I've managed to get instant results via tail's -F flag. While I'm able to filter for the last line, the first time it runs, when the file is updated, it outputs all the lines not just the last one (as desired).
tail -F -n 2 '/path/to/Epson4880_audit.txt' | grep "."