Bird
0
0

You execute find . -name '*.txt' but receive an error: find: missing argument to -name. What is the most probable cause?

medium📝 Debug Q6 of 15
Linux CLI - Searching and Finding
You execute find . -name '*.txt' but receive an error: find: missing argument to -name. What is the most probable cause?
AThe directory does not contain any <code>.txt</code> files.
BThe shell expanded the wildcard before <code>find</code> ran, leaving <code>-name</code> without a pattern.
CThe <code>find</code> command requires an absolute path, not <code>.</code>.
DThe <code>-name</code> option is deprecated and should be replaced with <code>-filename</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Understand shell expansion

    When using single quotes, the shell should not expand wildcards, but if quotes are missing or incorrect, the shell expands *.txt before find runs.
  2. Step 2: Effect on find

    If the wildcard expands to multiple files, -name may end up without a proper argument, causing the error.
  3. Final Answer:

    The shell expanded the wildcard before find ran, leaving -name without a pattern. -> Option B
  4. Quick Check:

    Check if wildcards are quoted properly. [OK]
Quick Trick: Always quote wildcards to prevent shell expansion [OK]
Common Mistakes:
  • Assuming no matching files causes this error
  • Thinking find requires absolute paths
  • Believing -name is deprecated

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes