I have a query ..
i have 2 scripts say 1.sh and 2.sh
1.sh contains many functions written using shell scripts.
2.sh is a script which needs to call the functions definded in 1.sh
function calls are with arguments.
Can some one tell me how to call the functions from 2.sh?
There is a better way of doing what you want to do using FPATH and/or autoload
For example, suppose you create the following directory within your home directory and put your function scripts in this directory. The filename should be the function name.
mkdir ~/.kshfunctions
In your .kshrc file, define the FPATH variable to point to that directory:
export FPATH=~/.kshfunctions
Functions will then be loaded on an as needed basis and results in faster script startup. To get a listing of which functions are actually currently loaded, just type 'functions' at the prompt. Use whence to find a function.
#!/usr/bin/ksh93
echo "in 2.sh"
fun1 "foo"
# fun1
function fun1
{
print "In function fun1 arg1->[$1]"
}