Question

Difficulty: MediumBasic 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.Answer
  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.

Answer

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.

Step-by-Step Solution

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).

Key Concept

Scripting language syntax and comment conventions (.sh vs .bat vs .vbs vs .js)
Rate this question