3
for a in bar do for b in 1000000 do montage -geometry 500 $a-$b-*-${0..20000..1000}.png \ $a-$b-${0..20000..1000}-final.jpg done done 

I'm unable to get all the images with number 0 1000 2000 ... 20000 using $(0..20000.1000) .

Is there an other way in shell to do this?

2 Answers 2

6

There must be no $ before {START..END..STEP}

% echo -{0..20000..1000}- -0- -1000- -2000- -3000- -4000- -5000- -6000- -7000- -8000- -9000- -10000- -11000- -12000- -13000- -14000- -15000- -16000- -17000- -18000- -19000- -20000- 

That being said, you need a loop to go over these numbers. The word containing a range is just replaced by its expansion. That means the command line is not called for each element alone, but for all of them together. It also means, that, even if you are using the same range twice, their expansion will not conveniently be combined.

Compare

% echo start a-{1..3}-b A-{1..3}-B end start a-1-b a-2-b a-3-b A-1-B A-2-B A-3-B end 

and

% for n in {1..3}; do echo start a-$n-b A-$n-B end; done start a-1-b A-1-B end start a-2-b A-2-B end start a-3-b A-3-B end 

So in your example instead of

montage -geometry 500 $a-$b-*-${0..20000..1000}.png \ $a-$b-${0..20000..1000}-final.jpg 

you probably want to do

for n in {0..20000..1000}; do montage -geometry 500 $a-$b-*-$n.png $a-$b-$n-final.jpg done 
Sign up to request clarification or add additional context in comments.

Comments

-4
#!/usr/bin/env python import os file_names= ["a","b"] ranges = list(xrange(0, 20000, 1000)) l_s = list() for f in range(0, len(file_names)): for a in range(0, len(ranges)): stringing = str(file_names[f]) + "--1000000-0-0-0-1-" + str(ranges[a]) + ".log.png" l_s.append(stringing) final = " ".join(l_s) foo = "montage -geometry 500 " + str(final) + " " + str(file_names[f])+ "-final.jpg" os.system(foo) 

2 Comments

Python did the job for me.
I know you were the OP, but you asked for a shell solution, so answering with a Python one is not helpful to the next guy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.