LFCA · Question #27
What command is used to view new content as it is written to a log file?
The correct answer is D. tail -f. The tail -f command is used to output the last part of files and then continuously monitor the file, appending new data as it is written to the file. This makes it ideal for real-time viewing of log files.
Question
What command is used to view new content as it is written to a log file?
Options
- Acat
- Bgrep -f
- Ccut -f1-5
- Dtail -f
How the community answered
(48 responses)- A4% (2)
- B2% (1)
- C2% (1)
- D92% (44)
Why each option
The `tail -f` command is used to output the last part of files and then continuously monitor the file, appending new data as it is written to the file. This makes it ideal for real-time viewing of log files.
The `cat` command concatenates and displays the entire content of a file to standard output at once; it does not continuously monitor for new content.
The `grep -f` command reads patterns from a file and searches for them in other files; it is used for pattern matching, not for continuously displaying new log file content.
The `cut` command is used to extract sections from each line of files, typically by bytes, characters, or fields; it is not designed for continuous monitoring of new file content.
The `tail -f` command displays the last portion of a file and then 'follows' it, continuously outputting new data as it is appended to the file. This is crucial for real-time monitoring of log files to observe events as they occur.
Concept tested: Linux log file monitoring
Source: https://man7.org/linux/man-pages/man1/tail.1.html
Topics
Community Discussion
No community discussion yet for this question.