Bird
0
0

Which of the following commands correctly uses find with -exec to list all .txt files in the current directory?

easy📝 Conceptual Q2 of 15
Linux CLI - Searching and Finding
Which of the following commands correctly uses find with -exec to list all .txt files in the current directory?
Afind . -name '*.txt' -exec mkdir {} \;
Bfind . -name '*.txt' -exec rm {} \;
Cfind . -name '*.txt' -exec ls -l {} \;
Dfind . -name '*.txt' -exec echo {}
Step-by-Step Solution
Solution:
  1. Step 1: Identify the command to list files

    The ls -l command lists files with details.
  2. Step 2: Check the syntax of -exec

    The command must end with \; to terminate the -exec action properly.
  3. Final Answer:

    find . -name '*.txt' -exec ls -l {} \; -> Option C
  4. Quick Check:

    Correct syntax with listing command = C [OK]
Quick Trick: End -exec commands with \; to run properly [OK]
Common Mistakes:
  • Omitting \; at the end
  • Using wrong commands like mkdir
  • Not quoting the pattern '*.txt'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes