There are a couple of different ways you can do this:
Make the other script executable, add the
#!/bin/bashline at the top, and the path where the file is to the $PATH environment variable. Then you can call it as a normal command;
Or call it with the
sourcecommand (alias is
.), like this:
Or use the
bashcommand to execute it, like:
The first and third approaches execute the script as another process, so variables and functions in the other script will not be accessible.
The second approach executes the script in the first script’s process, and pulls in variables and functions from the other script (so they are usable from the calling script).
In the second method, if you are using
exit in second script, it will exit the first script as well. Which will not happen in first and third methods.