Bird
0
0

A user runs tail -n 5 file.txt but gets the entire file output instead of last 5 lines. What could be wrong?

medium📝 Debug Q7 of 15
Linux CLI - Viewing and Editing Files
A user runs tail -n 5 file.txt but gets the entire file output instead of last 5 lines. What could be wrong?
Atail command is misspelled
BThe file has fewer than 5 lines
CThe file is empty
DThe user used head instead of tail
Step-by-Step Solution
Solution:
  1. Step 1: Understand tail behavior with small files

    If the file has fewer lines than requested, tail outputs the entire file.
  2. Step 2: Check other options

    Misspelling or empty file would cause errors or no output, not full file output.
  3. Final Answer:

    The file has fewer than 5 lines -> Option B
  4. Quick Check:

    tail outputs whole file if lines less than requested [OK]
Quick Trick: Tail outputs whole file if fewer lines than requested [OK]
Common Mistakes:
MISTAKES
  • Assuming tail always errors if file too short
  • Confusing head and tail
  • Ignoring file size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes