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 courses

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.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation 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 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?