Bird
0
0

What will be the output of cp -i file1.txt file2.txt if file2.txt already exists?

medium📝 Command Output Q4 of 15
Linux CLI - File and Directory Operations
What will be the output of cp -i file1.txt file2.txt if file2.txt already exists?
AIt overwrites file2.txt without asking
BIt copies file1.txt to a new file named file2.txt.bak
CIt throws an error and stops
DIt prompts before overwriting file2.txt
Step-by-Step Solution
Solution:
  1. Step 1: Understand the -i option

    The -i option means interactive. It asks for confirmation before overwriting an existing file.
  2. Step 2: Predict behavior if destination exists

    Since file2.txt exists, the command will prompt the user to confirm overwrite.
  3. Final Answer:

    It prompts before overwriting file2.txt -> Option D
  4. Quick Check:

    -i option = prompt before overwrite [OK]
Quick Trick: Use -i to confirm before overwriting files [OK]
Common Mistakes:
MISTAKES
  • Assuming automatic overwrite
  • Expecting error on existing file
  • Thinking it creates backup automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes