Bird
0
0

You want to write a script that always accesses the file data.csv located in /usr/local/share regardless of where the script runs. Which path should you use inside the script?

hard📝 Application Q8 of 15
Linux CLI - Navigating the File System
You want to write a script that always accesses the file data.csv located in /usr/local/share regardless of where the script runs. Which path should you use inside the script?
A../share/data.csv
B./data.csv
C/usr/local/share/data.csv
D~/usr/local/share/data.csv
Step-by-Step Solution
Solution:
  1. Step 1: Understand script location independence

    To access a file regardless of script location, use absolute path.
  2. Step 2: Choose correct absolute path

    /usr/local/share/data.csv is absolute and points directly to file.
  3. Final Answer:

    /usr/local/share/data.csv -> Option C
  4. Quick Check:

    Absolute path ensures consistent file access [OK]
Quick Trick: Use absolute path for fixed file locations [OK]
Common Mistakes:
  • Using relative paths that depend on current dir
  • Using '~' which is home, not absolute
  • Using '../' incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes