LFCS · Question #754
Which of the following commands will display the last 30 lines of /var/log/bigd.log as well as new content as it is appended to the file by another process?
The correct answer is C. tail-f-n 30/Var/log/bigd.log. The tail command with the -f and -n options displays the last specified number of lines of a file and then continues to output new content as it is appended.
Question
Options
- Acut-30-v/var/log/bigd.log
- BheaD.30-e/var/log/bigd.log
- Ctail-f-n 30/Var/log/bigd.log
- DtaC.30/var/log/bigd.log
- Ecat-r-n 30/var/log/bigd.log
How the community answered
(26 responses)- C88% (23)
- D4% (1)
- E8% (2)
Why each option
The `tail` command with the `-f` and `-n` options displays the last specified number of lines of a file and then continues to output new content as it is appended.
The `cut` command is used for extracting sections from lines of files and does not have options to display last lines or follow file content.
The `head` command displays the *first* lines of a file, not the last, and the `-e` option is not a standard way to follow file content.
The `tail` command is used to display the end of a file. The `-n 30` option specifies to show the last 30 lines, and the `-f` (follow) option keeps the command running, continuously outputting new data that gets appended to `/var/log/bigd.log` by another process, which is ideal for real-time log monitoring.
The `tac` command prints lines in reverse order, and `taC.30` is not valid syntax for displaying last lines or following a file.
The `cat` command concatenates and displays entire file contents and lacks options to show only the last lines or to follow appended content.
Concept tested: tail command for log monitoring
Source: https://man7.org/linux/man-pages/man1/tail.1.html
Topics
Community Discussion
No community discussion yet for this question.