Home > linux > Open multiple terminals in a for loop in bash

# Open multiple terminals in a for loop in bash

September 19Hits:1

Recently i changed to lxde on Ubuntu. And after switching it changed my x-terminal-emulator to lxterm.

My script was doing the following:

Go through a for loop and open a new terminal window and then run a script in that terminal. It would open multiple terminals at the same time running that script in all the different windows.

After switching to lxde it will loop through and wait for each terminal window to finish the script before the next terminal window launches. I want it to do what it was doing.

I fixed this issue by changing my x-terminal-emulator back to the gnome-terminal. Now it works fine. HOWEVER, this is a script system that a few people use and they are all using different environments and terminal emulators. How can i make sure this works for all the different terminal emulators or at least for xterm or whatever the one EVERYONE would have.

Thanks

Code snippet:

for blah in something do     x-terminal-emulator -e bash my_script.sh done 


This should do

for blah in something
do
x-terminal-emulator -e bash my_script.sh &
done



## Related Articles

• ### Open multiple terminals in a for loop in bashSeptember 19

Recently i changed to lxde on Ubuntu. And after switching it changed my x-terminal-emulator to lxterm. My script was doing the following: Go through a for loop and open a new terminal window and then run a script in that terminal. It would open multi

• ### On a linux server how do you use multiple terminals over a single ssh connection?May 1

I often find myself opening several ssh connections in order to view several log files at a time with tail -f. This isn't a problem when I'm at home because I use public key encryption for password-less login. However, I will often use computer at my

• ### Utility to send a command to multiple terminals?September 15

A while ago when I did a lot more system admining, there was a little utility that would send a command to multiple terminals that I had open. So essentially I could ssh into three different servers, then type tail -f /var/log/some_error.log into the

• ### How to place multiple form elements from a loopApril 3

I have a table that will have multiple table rows that are generated dynamically using a foreach loop. In these rows will be textfields using the Drupal forms API. Example: $f = '<table>';$f .= '<tr><td>Something...</td></tr>

• ### Can I login to multiple terminals with the same user safely on Linux?April 20

By terminals I mean the ones you can switch to using Ctrl+Alt+F1-F6. I know I'm able to login multiple times but does this have any side-effects? --------------Solutions------------- *NIX is by design a multi-user system, so there is not going to be

• ### Why does my computer show multiple terminals open Ubuntu 13.10November 25

I am running a c program that records the number of terminals open and then lists them but when I run it I am shown multiple terminal windows open when only the one is, why? --------------Solutions------------- The most likely reason is that there ar

• ### Creating multiple screens in a for loop to run parellel programs and sending commands to eachMarch 27

Before flagging this questions as redundant, i have read and tried every answer to similar questions with no success I have this loop where it traverses a directory structure, and runs a program (which takes minutes to finish) in each subdirectory in