On Wednesday 17 December 2008 22:42:34 Robert Bridge wrote:
> On Wed, 17 Dec 2008 15:33:35 -0500
>
> Willie Wong <ww...@princeton.edu> wrote:
> > 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.
>
> Or use a wildcard based match.
>
> name????stat.text works, as would name*stat.text

<pedantic>
name0[01][0-9]{2}stat.text
</pedantic>

would be better still

-- 
alan dot mckinnon at gmail dot com

Reply via email to