Deeper into Function Complexities with Shell Scripting – Part VII

If you have any questions or problems regarding this article and want help within 24 Hours? Ask Now

Support TecMint: Did you find this tutorial helpful?. Please help to keep it alive by donating. Every cent counts! - Donate Now

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.

Leave a Reply

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

Join Over 95000+ Linux Users
  1. 66,682
  2. 3,836
  3. 31,647

Enter your email to get latest Linux Howto's