Bash Scripting - BasicsYou want to write a script that works in both Bash and Zsh but uses arrays. Which syntax should you use?Adeclare -a array=(one two three)Bset -A array one two threeCarray=(one two three)Darray=one two threeCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify array syntax compatible with Bash and ZshBoth Bash and Zsh support array=(one two three) syntax.Step 2: Evaluate other optionsset -A is for ksh, declare -a is Bash-specific, and array=one two three is invalid.Final Answer:array=(one two three) -> Option CQuick Check:Compatible array syntax Bash & Zsh = array=(...) [OK]Quick Trick: Use array=(...) for Bash and Zsh arrays [OK]Common Mistakes:MISTAKESUsing declare -a which is Bash-onlyUsing set -A which is ksh syntaxAssigning array without parentheses
Master "Basics" in Bash Scripting9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Bash Scripting Quizzes Bash Scripting Basics - Making scripts executable (chmod +x) - Quiz 2easy Conditionals - if-elif-else - Quiz 4medium Conditionals - if-then-fi structure - Quiz 1easy Conditionals - Logical operators (-a, -o, !) - Quiz 2easy Quoting and Expansion - Escape characters (\) - Quiz 2easy Quoting and Expansion - Backticks and $() for command substitution - Quiz 5medium Quoting and Expansion - Why quoting rules prevent errors - Quiz 7medium Quoting and Expansion - Single quotes (literal strings) - Quiz 10hard User Input - read command - Quiz 4medium Variables - Environment variables vs local variables - Quiz 12easy