On 2013-03-04 04:42, Konstantin Khomoutov wrote:
> On Mon, 4 Mar 2013 08:45:05 +0100
> Geert Stappers <geert.stapp...@vanadgroup.com> wrote:
>
> [...]
>> Thank you for the tip. I want to share another.
>> It is about canceling multiple jobs. Execute from shell
>>
>>    for i in {17..21} ; do echo cancel yes jobid=404${i} | bconsole ;
>> done
>>
>> Five jobs, 40417-40421, will be canceled.
>
> A minor nitpick: the construct
>
> for i in {17..21}; do ...
>
> is a bashism [1], so it won't work in any POSIX shell.

A good point! I tried the above on FreeBSD:

$ cat test.sh
#!/bin/sh

for i in {17..21} ; do echo cancel yes jobid=404${i} ; done


[dan@bast:~/bin] $ ./sh test.sh
cancel yes jobid=404{17..21}
[dan@bast:~/bin] $

>
> A portable way to do the same is to use the `seq` program
>
> for i in `seq 17 21`; do ...
>
> or to maintain an explicit counter:
>
> i=17
> while [ $i -le 21 ]; do ...; i=$(($i+1)); done

Then I tried this approach but didn't find seq at all.  I tried sh, 
csh, and tcsh.

But I know about jot.  This does 5 numbers, starting at 17:

$ jot 5 17
17
18
19
20
21

Thus, the script becomes:

$ cat test.sh
#!/bin/sh

for i in `jot 5 17` ; do echo cancel yes jobid=404${i} ; done


$ sh ./test.sh
cancel yes jobid=40417
cancel yes jobid=40418
cancel yes jobid=40419
cancel yes jobid=40420
cancel yes jobid=40421



-- 
Dan Langille - http://langille.org/

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to