hi,

i am having two files

n.sh
here i wrote code like
clear
f()
{
echo "this is my program to test function"
}

again

i am having one more file

n1.sh

here i wrote like this

./home/selvam (this is my program directory (ie.. actual n.sh file is in this directory}

again i am calling the function

f -> this is function calling . this function already defined in n.sh file

but i was run this script it shows the error as

n1.sh: f : the command not found

what is solution to this problem

help to me

thanks

if n.sh doesn't contain anything but functions and variables (i.e. no actual executed code) then add ". <path>/n.sh" to the top of n1.sh. If n.sh is a full functional script, then you cannot do this. If you have common functions that you wish to use over multiple scripts, then place these functions into their own file (preferable without a "#!" line at the top). In this way, every script that wants to use those functions can include them using the "." line presented earlier.

From Dave_Sinulka's signature (CBoard member):

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan

This article has been dead for over six months. Start a new discussion instead.