How to use functions as a system commands?

I have few functions which do some things which i have programmed to do. I want them to use that functions anytime i want. Right now if i need to use that function i have to copied that to putty and then call that function. Is it possible to do that so that i don't need to call that function. And i can use that function like unix commands.

Thanks for your help.

pd:)

It is a little unclear what you want. I am guessing that you have written some functions that you might want to call from the shell command prompt any time, rather than having to write a script, define them in there and call them how you need each time.

I think that if you have these functions in a file (let's call it myfunctions) then you are wanting to make them available to the current shell. Try:-

. myfunctions

The leading "dot space" is important. This will execute the myfunctions file and load any functions to the current shell, so if you had:-

#myfunctions file
first()
{
 echo "Good morning!"
}

second()
{
 echo "Good afternoon!"
}

Then you could do the following:-

$ .  myfunctions
$ first
Good morning!
$ second
Good afternoon!
$

Is that the sort of thing you are after? If not, then do reply and explain where I have completely missed the point.

I hope that this helps
Robin
Liverpool/Blackburn
UK

Thanks Robin,

That what i want.

Thanks a lot

pd

You are welcome. As it is 14:10 GMT, please run my function called second

Robin
Liverpool/Blackburn
UK

2 Likes