Overview - Return values (return and echo)
What is it?
In bash scripting, functions can send back information using two main ways: return and echo. The return command sends a small number called an exit status, usually to show success or failure. Echo prints text to the screen or to another command, which can be captured as output. Understanding how to use both helps scripts communicate results clearly.
Why it matters
Without knowing the difference between return and echo, scripts can behave unpredictably or fail silently. Return values let scripts check if a task succeeded, while echo lets scripts pass data around. Without these, automation would be fragile and hard to debug, making tasks slower and more error-prone.
Where it fits
Before learning this, you should know basic bash commands and how to write simple functions. After mastering return and echo, you can learn about advanced error handling, command substitution, and script debugging techniques.