How to run sh file from another sh file

Create file1.sh

#! /bin/sh
echo "Hello World"

Create file2.sh

#! /bin/sh
details = `./file1.sh`
echo $details

give execute permission

chmod +x file1.sh
chmod +x file2.sh

Now run your file

./file2.sh

Output

Hello World

Take a look at this. If you want to run a script you can use:

./yourscript.sh

If your script has a loop, use:

./yourscript.sh&

If you want to get the console after starting scripts and you don't want to see it's output use:

./yourscript.sh > /dev/null 2>&1 &

So, in the master file you'll have:

./yourscript1.sh > /dev/null 2>&1 &
./yourscript2.sh > /dev/null 2>&1 &
./yourscript3.sh > /dev/null 2>&1 &

They will start together.

Tags:

Linux

Unix

Shell

Sh