I am running linux 2.6. On bash shell, i would like to source a file. If i am in the current directory as the source file, then i can do
source abc.sh
But if i am on some other folder, i would so
source /path-to/abc.sh
I would like to capture whatever is typed after the command source on the command line in my script, So, for example, i want access to “abc.sh” and in the latter case, i want access to “/path-to/abc.sh” inside abc.sh
Thank you
You are looking for the
$BASH_SOURCEvariable which contains currently processed script.For example if
/tmp/a.shis:Then:
You can find more on it in info bash.