How do I construct a terminal process that displays lines as they are added to a log file? [duplicate]
I'm needed to monitor a log file while I'm doing some debugging. The script I'm debugging writes to the terminal (STDIO) so having debugging info mixed in with that is annoying and I miss things.
What I would like to do is write my debugging info to a log file, simply appending each entry, and have a separate terminal window that is monitoring that file and displaying each entry as it is added.
Could I do something like:
echo << "=-EOF-="
where that somehow reads from the file and echoes each line until it encounters the magic termination string?
I have a feeling that this is possible, but I don't really know where to begin.
Any suggestions?
Thanks.
I'm on 10.14 Mojave, so I'm using Bash
Solution 1:
$ man tail
[... elided ...]
-f Don't stop when end of file is reached, but rather to wait for
additional data to be appended to the input. (ignored if the standard input is a pipe, but not if it is a FIFO)-F The -F option implies the -f option, but tail will also check to see if the file being followed has been renamed or rotated. The file is closed and reopened when tail detects that the filename being read from has a new inode number. The -F option is ignored if reading from standard input rather than a file.
https://ss64.com/osx/tail.html