Bird
0
0

In bash scripting, what is the main difference between return and echo inside a function?

easy🧠 Conceptual Q1 of 15
Bash Scripting - Functions
In bash scripting, what is the main difference between return and echo inside a function?
A<code>return</code> sends a status code, <code>echo</code> outputs text to the terminal
B<code>return</code> outputs text, <code>echo</code> sends a status code
C<code>return</code> and <code>echo</code> both output text
D<code>return</code> and <code>echo</code> both send status codes
Step-by-Step Solution
Solution:
  1. Step 1: Understand return in bash functions

    The return command sends an exit status (a number) from the function to the caller.
  2. Step 2: Understand echo in bash functions

    The echo command prints text to the terminal or standard output, not a status code.
  3. Final Answer:

    return sends a status code, echo outputs text to the terminal -> Option A
  4. Quick Check:

    Difference between return and echo = B [OK]
Quick Trick: Return sends status code; echo prints text [OK]
Common Mistakes:
MISTAKES
  • Thinking return outputs text
  • Confusing echo with return status
  • Assuming both do the same

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes