Bird
0
0

What will be the output of this command?

medium📝 Command Output Q13 of 15
Linux CLI - Searching and Finding
What will be the output of this command?
find /tmp -type f -name '*.txt' -exec echo File: {} \;
ADeletes all .txt files in /tmp directory.
BShows an error because <code>echo</code> cannot be used with <code>-exec</code>.
CLists only the names of .txt files without path.
DPrints 'File: ' followed by each .txt file path found in /tmp.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the command

    The command finds all files ending with .txt in /tmp and runs echo File: {} on each.
  2. Step 2: Predict output

    For each file found, it prints "File: " followed by the full file path (because {} is replaced by the path).
  3. Final Answer:

    Prints 'File: ' followed by each .txt file path found in /tmp. -> Option D
  4. Quick Check:

    -exec echo File: {} prints file paths [OK]
Quick Trick: Remember {} is replaced by each file path found [OK]
Common Mistakes:
  • Thinking it deletes files
  • Assuming only file names print without path
  • Believing echo can't be used with -exec

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes