Closed aadrian closed 6 years ago
Hi
Thanks for your question. Unfortunately the 'tail -f' feature does not fit very well into the unix4j philosophy of chaining commands. Hence we have no plans at the moment to implement this.
However a similar functionality can be found in Apache's Tailer: https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/input/Tailer.java
Hope this helps. Regards, Marco
... does not fit very well into the unix4j philosophy of chaining commands.
How comes?
tail -f /var/log/file.log | grep search_term
is a very used pattern.
and the equivalent of "chaining commands" would look like:
Unix4j.tail(Tail.Options.f, "/var/log/file.log").grep(...)
But the command blocks until you stop it with Ctrl-C --- how would you want to do this?
But the command blocks until you stop it with Ctrl-C --- how would you want to do this?
https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/input/Tailer.java is also requires Threads or Executor.
Yes --- and that does not fit well with the current very generic interface of unix4j. In particular to eventually execute the command you chose e.g. toStringList or other output methods. I am not worried about the thread, but about how to keep everything generic. I would have to somehow expose a "stop" method to abort the infinite tailing.
Sure this would be possible somehow but would likely require some changes in the current design. Unfortunately I don't have the resources to start such a project atm.
Hi,
Any chance getting the file monitor functionality option for
tail
? https://en.wikipedia.org/wiki/Tail_(Unix)#File_monitoringThank you.