Bash Scripting - BasicsWhat will be the output of this script run in sh but not in Bash?echo $(( 1 + 2 ))A3B1 + 2CSyntax errorDEmpty outputCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand arithmetic expansion supportBash supports $(( )) arithmetic expansion; many modern sh versions also support it.Step 2: Predict behavior in shMost modern sh shells support arithmetic expansion, so it outputs 3.Final Answer:3 -> Option AQuick Check:Arithmetic expansion supported in sh = Outputs 3 [OK]Quick Trick: Most sh versions support $(( )) arithmetic expansion [OK]Common Mistakes:MISTAKESAssuming sh does not support $(( ))Expecting syntax error in shThinking it prints expression literally
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