1

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?

1 Answers1

3

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.

Kusalananda
  • 333,661