0

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?

4
  • 1
    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). Jul 31, 2021 at 2:30
  • @steeldriver thanks for your answer, I did solve my issue adding watch's command. Aug 1, 2021 at 2:12
  • I was wondering if watch might provide a solution - please add an answer showing how you solved it Aug 1, 2021 at 2:33
  • 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. Aug 1, 2021 at 2:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.