There are a couple of ways you can do this. Terminal to execute the script:
#!/bin/bash
SCRIPT_PATH="/path/to/script.sh"
# Here you execute your script
"$SCRIPT_PATH"
# or
. "$SCRIPT_PATH"
# or
source "$SCRIPT_PATH"
# or
bash "$SCRIPT_PATH"
# or
eval '"$SCRIPT_PATH"'
# or
OUTPUT=$("$SCRIPT_PATH")
echo $OUTPUT
# or
OUTPUT=`"$SCRIPT_PATH"`
echo $OUTPUT
# or
("$SCRIPT_PATH")
# or
(exec "$SCRIPT_PATH")
There are a couple of ways you can do this. Terminal to execute the script:
All this is correct for the path with spaces!!!
You can use
/bin/sh
to call or execute another script (via your actual script):The output would be:
Check this out.
Simple source will help you. For Ex.
Assume the new file is "/home/satya/app/app_specific_env" and the file contents are as follows
Append this file reference to ~/.bashrc file
When ever you restart the machine or relogin, try
echo $FAV_NUMBER
in the terminal. It will output the value.Just in case if you want to see the effect right away,
source ~/.bashrc
in the command line.Just add in a line whatever you would have typed in a terminal to execute the script!
e.g.:
if the script to be executed is not in same directory, just use the complete path of the script.
e.g.:`/home/user/script-directory/./myscript.sh &