Bird
0
0

You want to extract lines 10 to 15 from a large file logfile.txt using only head and tail. Which command achieves this?

hard📝 Application Q8 of 15
Linux CLI - Viewing and Editing Files
You want to extract lines 10 to 15 from a large file logfile.txt using only head and tail. Which command achieves this?
Ahead -n 15 logfile.txt | tail -n 7
Btail -n +10 logfile.txt | head -n 5
Chead -n 15 logfile.txt | tail -n 5
Dtail -n +10 logfile.txt | head -n 6
Step-by-Step Solution
Solution:
  1. Step 1: Use tail to start from line 10

    tail -n +10 logfile.txt outputs from line 10 to end.
  2. Step 2: Use head to limit output to 6 lines (lines 10 to 15)

    head -n 6 takes first 6 lines from that output, lines 10 to 15.
  3. Final Answer:

    tail -n +10 logfile.txt | head -n 6 -> Option D
  4. Quick Check:

    Combine tail +N and head -n M for line ranges [OK]
Quick Trick: Use tail -n +start | head -n count for line ranges [OK]
Common Mistakes:
  • Using wrong number of lines in head or tail
  • Swapping head and tail order
  • Using incorrect line counts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes