3

I need to open a new terminal tab and execute multiple commands on it, how can I do it. I have already tried the following,

gnome-terminal --tab -t "X" -e "cd ~/Desktop/terminal_test;mkdir test"

Here I need to cd into a new directory and create a new folder.

2 Answers 2

3

Try this:

gnome-terminal -x bash -c "cmd1; cmd2; …cmdN; exec bash"
Sign up to request clarification or add additional context in comments.

2 Comments

@ycrnet I modified it
Thanks alot, this works, The complete command would be gnome-terminal --tab -t "XXX" -x bash -c "cd ~/Desktop/terminal_test; mkdir test; exec bash
0

You can use gnome-terminal. The script below will open 3 tabs running the respective commands..

tab="--tab"

cmd01="bash -c 'ls';'pwd';bash"

foo=""

foo+=($tab -e "$cmd01")

gnome-terminal "${foo[@]}"

exit 0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.