Bash Scripting - ArraysWhich of the following is the correct syntax to declare an empty indexed array named items in Bash?Aitems=''Bitems=[]Citems={}Ditems=()Check Answer
Step-by-Step SolutionSolution:Step 1: Recall how to declare empty arrays in BashEmpty indexed arrays are declared with parentheses and no elements inside.Step 2: Evaluate each optionitems=() uses parentheses correctly. Options B and C use square and curly brackets which are invalid. items='' assigns an empty string, not an array.Final Answer:items=() -> Option DQuick Check:Empty Bash array declaration = items=() [OK]Quick Trick: Use empty parentheses to declare empty arrays [OK]Common Mistakes:MISTAKESUsing square or curly brackets instead of parenthesesAssigning empty string instead of empty arrayForgetting parentheses altogether
Master "Arrays" in Bash Scripting9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Bash Scripting Quizzes Arrays - Accessing array elements - Quiz 11easy Arrays - Why arrays handle lists of data - Quiz 15hard Error Handling - trap for cleanup on exit - Quiz 2easy Error Handling - Error logging patterns - Quiz 11easy Functions - Function arguments ($1, $2 inside function) - Quiz 1easy Functions - Calling functions - Quiz 7medium Functions - Function libraries (sourcing scripts) - Quiz 14medium Functions - Function arguments ($1, $2 inside function) - Quiz 5medium Text Processing in Scripts - Why scripts often process text - Quiz 12easy Text Processing in Scripts - Here documents (<<EOF) - Quiz 3easy