Bird
0
0

You want to count the total number of lines in multiple files: file1.txt, file2.txt, and file3.txt. Which command gives the total lines combined?

hard📝 Application Q8 of 15
Linux CLI - Viewing and Editing Files
You want to count the total number of lines in multiple files: file1.txt, file2.txt, and file3.txt. Which command gives the total lines combined?
Awc -l file1.txt file2.txt file3.txt | tail -1
Bwc -l file1.txt file2.txt file3.txt | head -1
Cwc -l file1.txt file2.txt file3.txt | grep total
Dwc -l file1.txt file2.txt file3.txt | grep -v total
Step-by-Step Solution
Solution:
  1. Step 1: Understand wc -l output for multiple files

    It lists line counts per file and a final total line count line.
  2. Step 2: Extract total line count

    The last line of output shows the total lines; tail -1 gets this line.
  3. Final Answer:

    wc -l file1.txt file2.txt file3.txt | tail -1 -> Option A
  4. Quick Check:

    Total lines = last line of wc -l output [OK]
Quick Trick: Use tail -1 to get total line count from multiple files [OK]
Common Mistakes:
MISTAKES
  • Using head -1 which shows first file only
  • Searching for 'total' which is not printed by wc
  • Filtering out total line accidentally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes