bash functions bash function arguments

Bash functions bash function arguments

Bash functions

functions in bash used to perform repetitive tasks , we can put all task or command in one function and we can used it by just calling function name.

Creating Functions


functionName () {
list of commands


Bash function arguments


Returning Values from Functions


Nested Functions

Nested function is function within function



Explanation : in the above example we can see that we only called FunctionOne and then FunctionOne called to FunctionTwo

Bonus Example script of function in bash

In below script we have created some function to get the Total size of RAM, CPU details ,Total core of CPU and Ubuntu Server version, we are using case for menu selection.

Note: In case *) is for value which is not match in case value.

You May Also Enjoy Reading This …

Leave a Reply

Your email address will not be published. Required fields are marked *