Bird
0
0

You want to copy only files (not directories) from source to dest. Which command achieves this?

hard📝 Application Q9 of 15
Linux CLI - File and Directory Operations
You want to copy only files (not directories) from source to dest. Which command achieves this?
Acp -r source/* dest/
Bcp source/* dest/
Cfind source -type f -exec cp {} dest/ \;
Dcp -a source dest/
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirement

    Copy only files, no directories.
  2. Step 2: Analyze options

    cp -r copies directories recursively, cp source/* dest/ copies top-level files but omits directories and hidden files, cp -a copies everything preserving attributes.
  3. Step 3: Use find with -type f

    find source -type f -exec cp {} dest/ \; finds only files and copies them individually.
  4. Final Answer:

    find source -type f -exec cp {} dest/ \; -> Option C
  5. Quick Check:

    Copy only files = find + cp [OK]
Quick Trick: Use find with -type f to copy only files [OK]
Common Mistakes:
  • Using cp -r copies directories too
  • Assuming cp * excludes directories
  • Using -a copies everything

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes