Bird
0
0

Which of the following is the correct syntax to display the last 5 lines of a file named log.txt?

easy📝 Syntax Q12 of 15
Linux CLI - Viewing and Editing Files
Which of the following is the correct syntax to display the last 5 lines of a file named log.txt?
Atail -n 5 log.txt
Bhead -n 5 log.txt
Ctail 5 log.txt
Dhead 5 log.txt
Step-by-Step Solution
Solution:
  1. Step 1: Identify the command to show last lines

    tail shows the end of a file, so it is used to show last lines.
  2. Step 2: Use correct syntax with -n option

    The option -n 5 specifies to show 5 lines. So tail -n 5 log.txt is correct.
  3. Final Answer:

    tail -n 5 log.txt -> Option A
  4. Quick Check:

    tail -n 5 shows last 5 lines [OK]
Quick Trick: Use -n with tail to specify number of lines [OK]
Common Mistakes:
MISTAKES
  • Using head instead of tail
  • Omitting -n option
  • Using tail without -n for line count

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes