A Linux administrator is troubleshooting an automated system maintenance script saved with a `.sh` file extension. The script needs to verify whether a destination directory stored in an environment variable named `TARGET_PATH` exists before initiating a file copy operation. However, the script generates a syntax error at execution. Which of the following represents the correct syntax to reference this environment variable in a Linux Bash shell script?
- $TARGET_PATHAnswer
- B%TARGET_PATH%
- C$env:TARGET_PATH
- Dvar TARGET_PATH
Answer
The syntax $TARGET_PATH correctly references environment variables within a Linux Bash shell script.
In Linux Bash shell scripts (`.sh`), environment variables are accessed by prefixing the variable identifier with a dollar sign (` TARGET_PATH` or `${TARGET_PATH}`.
Step-by-Step Solution
Key Concept
Environment Variable Syntax in Shell Scripts
Estimated Time:1m 0s