Cloudkul Support

How to use functions and variables of another shell script ?

Suppose we have two shell scripts
1. script-1.sh
2. script-2.sh

Suppose script-2.sh contains a function called someFunction(). Script-1.sh can not call the function someFunction(). To able to call the function you have to add the following line in script-1.sh .

source script-2.sh

Now, script-1.sh will be able to call all the functions and variables inside script-2.sh

Is this article is helpful?

People like and 0 people dislike.

If result is not found or irrelevant, Please contact us.

Submit your request

Start a Project




    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home