Run a shell script in new terminal from current terminal

linux, shell, terminal

Solution

Here's a simple example to get you started:

To write a shell script, do this on your command prompt:

echo -e '#!/bin/sh\n echo "hello world"' > abc.sh

This writes:

#!/bin/sh
echo "hello world"

To a file called `abc.sh`

Next, you want to set it to executable by:

chmod +x abc.sh

Now, you can run it by:

./abc.sh

And you should see:

hello world

On your terminal.

To run it in a new terminal, you can do:

gnome-terminal -x ./abc.sh

or, if it's `xterm`:

xterm -e ./abc.sh

Here's a list of different terminal emulators.

Alternatively, you just run it in your current terminal, but background it instead by:

./abc.sh &

Problem

How do you run a shell script in a new terminal in Linux from a terminal like "start test.bat" in Windows, also it should be working in the console mode.

Original source