A system administrator is developing a Bash shell script (.sh) to automate daily system backups. While attempting to set a variable for the maximum allowed backup retry attempts, the administrator adds the line `RETRY_COUNT = 5` to the script. When executing the script in a Linux terminal, the shell returns the error message `RETRY_COUNT: command not found`. Which of the following best explains the cause of this error?
- Bash interprets spaces around the equals sign as separating a command name from its arguments rather than performing a variable assignment.Cevap
- BVariables in Bash must include a leading dollar sign during assignment, such as `$RETRY_COUNT = 5`.
- CBash requires all user-defined variables to be initialized using the `set` command prior to assignment.
- DInteger values assigned within shell scripts must be enclosed in double quotation marks to be recognized as valid literal values.
Cevap
Bash interprets spaces around the equals sign as separating a command name from its arguments rather than performing a variable assignment.
In Linux shell scripting (Bash), variable assignment is strictly whitespace-sensitive. The syntax requires `VARIABLE=value` with no spaces surrounding the equals sign. When spaces are introduced (`RETRY_COUNT = 5`), the shell treats `RETRY_COUNT` as the program/command to execute and passes `=` and `5` as parameters. Because no executable named `RETRY_COUNT` exists in the environment path, the terminal returns a `command not found` error.
Adım Adım Çözüm
Anahtar Kavram
Bash Scripting Variable Assignment Syntax