Deeper into Function Complexities with Shell Scripting – Part VII

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux course in 5 Days

We are thankful for your never ending support.

Anoop C S

I am basically a FOSS enthusiast interested in working under GNU/Linux and system administration. Looking forward to become a part of an open source initiative. Currently pursue Computer Science & Engineering.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

2 Responses

  1. Anoop C S says:

    Try to understand the difference based on the output of following shell script:

    #!/bin/bash

    function return_func () {
    echo “I’m returning, but not exiting . . .”
    return 1
    echo “This will not be displayed :-)”
    }

    function exit_func () {
    echo “I’m exiting . . .”
    exit 0
    echo “This will not be displayed :-)”
    }

    echo
    echo “Before returning.”
    echo
    return_func
    if [ $? -eq 1 ]; then
    echo
    echo “Before exiting.”
    echo
    exit_func
    fi
    echo
    echo “And you will not see this on execution”
    exit 2

    Check the output status using $? immediately after the execution of the above script. I hope that’s clear.

  2. Aaron Kili K says:

    what is the difference between a return statement and an exit statement in shell functions.

    Could you explain with some brief examples.

Got something to say? Join the discussion.

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

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's