1

I'm trying to write a one-liner that uses a forloop to start multiple screen (so, parallel), where in each screen another for-loop is ran (so, sequentially).

Any help would be appreciated

My attempt is to use a for-loop that makes named screens (screen -dmS) followed by screen -x NAME -X $somecommand, where $somecommand is in itself that has for-loops in it, but it doesn't yet work fully.

I've gotten closer and closer using some posts on stack overflow, but still didn't quite get there. This is what I got so far:

for b in $(seq -s ' ' 0.000 0.005 0.020); do command="for s in {1..3}; do for h in $(seq -s ' ' 0.000 0.010 0.030); do ./MultiGene -s $s -b $b -h ${h} -m 0.0 -u 0.0 -l 0.02 -name WM ${h}_b${b} -mix -w 0.3; done; done;"; screen -dmS "b${b}"; screen -x "b${b}" -X $command; done

Now, this doesn't give me a single error, and the screens get started, but nothing is happening inside the screens. So the second bit where I use -X doesn't seem to work (although this normally gives an error?)

What I want is that the started screens actually all have started their own respective for-loop.

Cheers!

PS I know there's plenty of other ways to do this, but for now I really want to solve this puzzle ;)

user2810298
  • 111
  • 9
  • one liners are highly overrated. Get your code so the structure is apparent, and when you have it all working as needed you can fold it back up into one line. (I'd recommend you do that your Q above, note no one is jumping in to help on this one) . Good luck. – shellter Sep 21 '19 at 15:27
  • And you might want to read by conversation with another person trying to *abuse* `screen` ;-) .... https://stackoverflow.com/questions/57731281/automatically-paste-commands-in-multiple-processes-of-a-screen-session . Good luck. – shellter Sep 21 '19 at 16:01
  • I actually enjoy abusing bash with terrible one-liners. It can be quite helpful to compress something like that. Anyhoo, thanks for the tips. – user2810298 Sep 23 '19 at 10:18

0 Answers0