Run a shell script in new terminal from current terminal

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 &

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)