Bash Functions

Bash functions are same as functions in other programming langs. Here is a little demo about Bash functions. I like Bash functions because it increase the re-usability and the organization of the code.

function function_B {
        echo "I am Function B."
function function_A {
        echo $1
function function_D {
        echo "I am Function D."
function function_C {
        echo $1
function_A "Call Function A."
function_C "Call Function C."


Call Function A.
I am Function B.
Call Function C.
I am Function D.

Few facts about Bash Functions;

  • There is no order to declare functions.
  • No brackets when calling the function.
  • Arguments that pass to the function can be identified as $1 $2 with in the function code block.

Then have fun with Bash Functions . . .


Please add your valuable idea below, will make a discussion, thanks !

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s