Skip to content
Advertisement

How can I run a function from a script in command line?

I have a script that has some functions.

Can I run one of the function directly from command line?

Something like this?

myScript.sh func()

Advertisement

Answer

If the script only defines the functions and does nothing else, you can first execute the script within the context of the current shell using the source or . command and then simply call the function. See help source for more information.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement