Bird
0
0

Identify the error in the following Bash array declaration:

medium📝 Debug Q6 of 15
Bash Scripting - Arrays
Identify the error in the following Bash array declaration:
myarray=(apple, banana, cherry)
AParentheses should be replaced with square brackets
BCommas should not be used between elements
CElements must be quoted
DArray name cannot contain 'my'
Step-by-Step Solution
Solution:
  1. Step 1: Check array element separators in Bash

    Bash arrays use spaces to separate elements, not commas.
  2. Step 2: Analyze the given declaration

    Commas between elements cause syntax errors; they must be removed.
  3. Final Answer:

    Commas should not be used between elements -> Option B
  4. Quick Check:

    No commas between array elements in Bash [OK]
Quick Trick: Separate array elements with spaces, not commas [OK]
Common Mistakes:
MISTAKES
  • Using commas between elements
  • Misusing brackets for array declaration
  • Thinking array names have naming restrictions like 'my'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes