Soru

Zorluk: OrtaBasic Scripting Languages and Constructs

A desktop support specialist is customizing an automated system maintenance script with a .sh file extension to execute on Linux and macOS workstations. To document recent configuration updates, the specialist needs to insert internal documentation lines into the script that will be ignored by the shell command interpreter during execution. Which syntax must the specialist use to denote commented lines in this script?

  1. Prepend each commented line with the # character.Cevap
  2. B
    Prepend each commented line with the REM keyword.
  3. C
    Prepend each commented line with a single quote (') character.
  4. D
    Prepend each commented line with a double slash (//) prefix.

Cevap

Prepend each commented line with the # character.
In Bash shell scripts (.sh), placing a hash character (#) at the start of a line instructs the shell command interpreter to treat that text as a comment and ignore it during script execution.

Adım Adım Çözüm

1
Identify the scripting environment based on the file extension.
The file extension .sh indicates a Unix/Linux Bash shell script.
Scripting languages use distinct comment syntax depending on their execution runtime environment.
2
Determine the standard comment syntax for Bash shell scripting.
The hash symbol (#) designates a single-line comment in Bash scripts.
The shell interpreter ignores any line or portion of a line following the # symbol (except for the shebang line #! at the very top).

Anahtar Kavram

Scripting language syntax and comment conventions (.sh vs .bat vs .vbs vs .js)
Bu soruyu puanla