nerdexam
CompTIA

LX0-103 · Question #154

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 -f and -n flags is the correct tool to both display the last N lines of a file and continuously follow new appended content. The other choices use incorrect commands or invalid syntax.

GNU and Unix Commands

Question

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?

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

(25 responses)
  • A
    4% (1)
  • C
    92% (23)
  • D
    4% (1)

Why each option

The tail command with -f and -n flags is the correct tool to both display the last N lines of a file and continuously follow new appended content. The other choices use incorrect commands or invalid syntax.

Acut-30-v/var/log/bigd.log

cut is a text-processing command used to extract fields or columns from lines; it has no capability to display lines from the end of a file or follow new content.

BheaD.30-e/var/log/bigd.log

head displays the first lines of a file, not the last, and does not support following appended content; this option also contains garbled syntax.

Ctail-f-n 30/Var/log/bigd.logCorrect

tail -f tells the command to follow the file and print new data as it is appended by other processes, which is the standard way to monitor live log files. The -n 30 option sets the initial output to the last 30 lines, satisfying both requirements in the question. The path /var/log/bigd.log is correctly specified with the proper case.

DtaC.30/var/log/bigd.log

tac outputs a file in reverse line order and does not support following live appended content.

Ecat-r-n 30/var/log/bigd.log

cat does not accept -r or a numeric -n argument for limiting output to a trailing number of lines, and it does not follow file changes.

Concept tested: tail -f command for live log monitoring

Source: https://man7.org/linux/man-pages/man1/tail.1.html

Topics

#tail command#log files#real-time monitoring#command line utilities

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice