Execute command from file in current shell [duplicate]
Use builtin command source
(from help -m source
):
source - Execute commands from a file in the current shell.
Example of execution mentioned in Question:
pandya@pandya-desktop:~$ source ch_dir
pandya@pandya-desktop:/usr$
Here you can see cd /usr
is executed in current shell and hence directory of current shell changed!
Hope this will help to execute command input from file in current shell.
Just run the script with a .
like this:
pandya@pandya-desktop:~$ . ./ch_dir