On Wed, Dec 17, 2008 at 08:48:52AM +0000, Mick wrote:
> On Sunday 14 December 2008, Neil Bothwick wrote:
> > On Sun, 14 Dec 2008 11:47:51 +0200, Alan McKinnon wrote:
> > > That's why I suggested them :-) I use them a lot, especially when I
> > > have to run the same set of commands on 15 different hosts, then I do
> > > something like:
> > >
> > > for I in $(seq 1 15) ; do
> >
> > If you're using bash or zsh,you can speed this up with
> >
> > for I in {1..15}; do
> 
> Hmm, I tried this with a sequence of files that look like name0001stat.txt to 
> name0198stat.txt, but when I run {0001..0198} it fails because it seems to 
> ignore the zeros in 0001 and start counting from 1.  Do I need to use some 
> escape character for this?

This is one place bash's brace expansion is sorely lacking compared to
zsh. In this case you need to use the seq command from coreutils. See
man seq for more info.

In your particular case, you can do 

for I in $(seq -w 198); do ... 0$I ; done

seq is more flexible in that it allows arbitrary formatting of the
sequence using printf floating-point format. 

W

-- 
Willie W. Wong                                      ww...@math.princeton.edu
408 Fine Hall,  Department of Mathematics,  Princeton University,  Princeton
A mathematician's reputation rests on the number of bad proofs he has given.

Reply via email to