Bird
0
0

What will be the output of this script run in Bash but not in Fish?

medium📝 Command Output Q13 of 15
Bash Scripting - Basics
What will be the output of this script run in Bash but not in Fish?
echo $(( 3 + 4 ))
A7
B3 + 4
CSyntax error
D7 with a newline and prompt
Step-by-Step Solution
Solution:
  1. Step 1: Understand arithmetic expansion in Bash

    Bash supports $(( expression )) syntax to calculate arithmetic expressions and outputs the result.
  2. Step 2: Behavior in Fish shell

    Fish does not support $(( )) syntax; it would cause an error or print the expression literally.
  3. Final Answer:

    7 -> Option A
  4. Quick Check:

    Bash arithmetic expansion = 7 [OK]
Quick Trick: Bash uses $(( )) for math; Fish does not support it [OK]
Common Mistakes:
MISTAKES
  • Expecting Fish to evaluate $(( ))
  • Confusing output with syntax error
  • Thinking output includes prompt

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes