-1

I want to run several jobs in parallel using the a script that does serial calls to a parameterized script and submits it as a background job on each call. It's for a brute force script which on each call will run 1k of 10k total combinations.

The following is my first hack at it.

#!/bin/bash for i in $(seq 10) do ./tmp/tmpsky/bd25Par.sh (i*1000-1000) (i*1000) & done 

I want $1 to evaluate as 0,1000,2000 etc...and $2 to evaluate to 1000,2000,3000 etc.

The & is to submit the script as a background job. The called module will pass $1 and $2 to be used with seq as follows

#/bin/bash/ for n in $(seq $1 1 $2) do ...` 

The first script fails with unexpected token 'i*1000-1000'

What have I done wrong?

2
  • This is what parallel is for. Commented Sep 28, 2016 at 4:16
  • @Theophrastus yes that seemed to work..! Commented Sep 28, 2016 at 4:33

1 Answer 1

1

The first script fails with unexpected token 'i*1000-1000'

What have I done wrong?

The obvious error is that you are actually not calling the variable $i in your loop:

for i in $(seq 10) do ./tmp/tmpsky/bd25Par.sh (i*1000-1000) (i*1000) & done 

It should be:

for i in $(seq 10) do ./tmp/tmpsky/bd25Par.sh ($i*1000-1000) ($i*1000) & done 

Thus; use $i when using the variable. i in itself will not work.

As far as doing math in the shell, see comment number 2.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.