Bird
0
0

A script uses wc -w file.txt but the output is zero even though the file has text. What could be the problem?

medium📝 Debug Q7 of 15
Linux CLI - Viewing and Editing Files
A script uses wc -w file.txt but the output is zero even though the file has text. What could be the problem?
AThe file has no newline at end
BThe file is empty
CThe file contains only whitespace characters
DThe wc command is missing
Step-by-Step Solution
Solution:
  1. Step 1: Understand word counting behavior

    wc -w counts words separated by spaces or newlines; whitespace alone is not counted as words.
  2. Step 2: Analyze zero output despite text

    If file has only spaces or tabs but no actual words, word count is zero.
  3. Final Answer:

    The file contains only whitespace characters -> Option C
  4. Quick Check:

    Whitespace-only file = zero words [OK]
Quick Trick: Words need non-whitespace characters to count [OK]
Common Mistakes:
  • Assuming newline absence causes zero words
  • Thinking empty file and whitespace-only file are same
  • Assuming missing command causes zero output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes