Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute bash script in same shell

Tags:

bash

I have a bash script which is calling three different commands and that execution must happen in one shell. I got it by adding && after each command like as follows-

CMD1 && CMD2 && CMD3

Now what i need is- lets say i open a terminal on my MAC machine, all commands should run in open shell not in new sub-shell.

As a side note- CMD1 is actually a source command to my project directory which is a bash script which sets all the environment variable for running server.

like image 367
Sam Avatar asked May 22 '17 21:05

Sam


1 Answers

First, you will need to save save the command in a scriptfile, for example Myscript.sh.

Second, you can execute the script file to run your commands simultaneously using

. ./Myscript.sh

The first . stands for current shell and the second . for current directory.

like image 185
Nikhil Fadnis Avatar answered Sep 18 '22 08:09

Nikhil Fadnis