Problem
In Linux, I have a log file in.csv format that is constantly updated. I’d like to watch the log file while it’s being updated. Is there a command(s) in Linux that can accomplish this?
Asked by Ashwin
Solution #1
tail -f yourlog.csv
Newly added lines will be displayed continuously.
Answered by teerapap
Solution #2
The most typical method, as others have mentioned, is tail -f file. The issue is that the results simply scroll by, and you can’t go back and search them unless your terminal supports it and you have enough lines buffered.
Less is a less well-known alternative that I prefer; if you type Shift-F when viewing a file with less, it will begin following the file’s finish, just like tail -f. You can also start less with less +F to enter this mode right away. You can stop following the file at any time by pressing Ctrl-C, then page up and down, search with /, and utilize less as usual. This is particularly useful if you notice anything intriguing in the log but it scrolls off screen, or if you want to go back and double-check something you may have overlooked. After you’ve finished looking around, press Shift-F to resume following the file.
If you examine many files with tail -f, they will all be interleaved (with headers to differentiate them), which may not be the way you want to see them.
tail -F (capital -F, not lowercase -f) is a non-standard flag (available on Linux, Cygwin, MacOS X, FreeBSD, and NetBSD) that works better for monitoring log files that are rotated on a regular basis; it’s common for a process to rename a log file and then create a new log file in its place to avoid any one log file becoming too large. tail -f will continue to follow the old file, which is no longer the active log file, but tail -F will monitor for the creation of a new file and begin following it instead. You can use the —follow-name flag to make less act in this way if you’re using less to follow the file.
(Thanks to ephemient for the less +F and less —follow-name suggestions)
Answered by Brian Campbell
Solution #3
tail -f foo.csv
Answered by Pete
Solution #4
If you need to keep track of numerous files, there’s a handy tool called multitail that allows you to combine the output from two or more files and track them in real time. You can also go back and forth in the monitored file with multitail (s).
Answered by gareth_bowles
Solution #5
tail -f and its ilk are from a bygone era. Although multitail appears to be a better option, glTail is the best way to burn your CPU while watching your log files.
Answered by Noufal Ibrahim
Post is based on https://stackoverflow.com/questions/2099149/view-a-log-file-in-linux-dynamically