Say I've got a text file file.txt and program program.rb. program.rb writes stuff to file.txt as program.rb finds it. How can I view the population of the text file from the terminal?

  • tail -f file.txt ?
    – user14755
    Aug 16 '16 at 4:07

This is commonly done with tail -f:

$ tail -f file.txt

The tail utility outputs the tail of a file or stream, i.e. the last part of it (the 10 last lines by default). With the -f flag, it will not exit once it has arrived at the end, but continue polling the file or stream for new data and output it whenever it arrives.

This is commonly done to manually monitor log files, or, as in your case, to view the partial result of a running program.

See also question 291932 to learn the difference between tail -f and tail -F.

  • Another possibility is to view the file with less and press Shift + F.
    – egmont
    Aug 16 '16 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.