Score:0

How to listen a result from a command using tail?

mx flag

I would like to perform this command:

tail -f | tac myfile.txt

tac reverts the order of the lines, the command works fine, except for the "listen" part.

When the file is updated, the tail command doesn't update the console.

Is it possible to perform this?

hr flag
When you do `tail -f | tac myfile.txt`, the `tail -f` command is tailing standard input, while `tac` is (separately) reversing the `myfile.txt` - nothing actually gets piped from one to the other afaik. OTOH if you do `tail -f myfile.txt | tac`, the `tac` is going to hang waiting for `tail -f` to finish (because it can't seek to the end of standard input).
mx flag
@steeldriver thanks for your answer, I did solve my issue adding `watch`'s command.
hr flag
I was wondering if `watch` might provide a solution - please add an answer showing how you solved it
mx flag
This was my solution @steeldriver `watch -n 0.5 "tail -n -50 /filepath/filename.txt | tac"`, it's not exactly what I was looking for, but solves the issue for my personal use.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.