Bird
0
0

In a script, you want to copy a file from user john's home directory to the current directory. Which command correctly uses tilde expansion?

hard🚀 Application Q9 of 15
Bash Scripting - Quoting and Expansion
In a script, you want to copy a file from user john's home directory to the current directory. Which command correctly uses tilde expansion?
Acp ~john/file.txt .
Bcp ~/john/file.txt .
Ccp ~ /john/file.txt .
Dcp /~john/file.txt .
Step-by-Step Solution
Solution:
  1. Step 1: Recall tilde for other user's home

    ~john expands to John's home directory.
  2. Step 2: Check path correctness

    cp ~john/file.txt . correctly copies file from John's home. Others have invalid syntax or wrong paths.
  3. Final Answer:

    cp ~john/file.txt . -> Option A
  4. Quick Check:

    Use ~username/path for other user's files [OK]
Quick Trick: Use ~username/path to access other user's files [OK]
Common Mistakes:
MISTAKES
  • Adding space between ~ and username
  • Using ~/username which is wrong
  • Starting path with /~username

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes