Bird
0
0

You want to write a script that lists files in the Documents folder inside the current user's home directory. Which command correctly uses tilde expansion?

hard🚀 Application Q8 of 15
Bash Scripting - Quoting and Expansion
You want to write a script that lists files in the Documents folder inside the current user's home directory. Which command correctly uses tilde expansion?
Als /~Documents
Bls ~ /Documents
Cls ~Documents
Dls ~/Documents
Step-by-Step Solution
Solution:
  1. Step 1: Understand tilde with subdirectory

    ~ expands to home directory; appending /Documents accesses that folder.
  2. Step 2: Check syntax correctness

    ls ~/Documents is correct. Spaces or wrong placement break expansion.
  3. Final Answer:

    ls ~/Documents -> Option D
  4. Quick Check:

    Use ls ~/folder for home subfolders [OK]
Quick Trick: No spaces: ~/folder accesses home subfolder [OK]
Common Mistakes:
MISTAKES
  • Adding space between ~ and /Documents
  • Using ~Documents which is invalid
  • Starting path with /~ which is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes