Back to Cosmos

Functions in Shell Scripting

code/shell_script/functions/README.md

latest647 B
Original Source

Functions in Shell Scripting

Functions are subsets of a code that implement an independent programming logic. For example, to create a four function calculator, independent programming logic are:

  1. Addition function
  2. Multiplication function
  3. Division function
  4. Subtraction function

Function allows us to divide a larger problem into smaller independent problem which may lead to better understandability and debugging.

One major advantage of functions are code reuse. A function, once written, need not to be defined again for doing a same task. A task can be done in repetition easily with a function call using the function name.