Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] One line script for md5sum
Date: Wed, 17 Dec 2008 22:17:45
Message-Id: 200812180017.18944.alan.mckinnon@gmail.com
In Reply to: Re: [gentoo-user] [OT] One line script for md5sum by Robert Bridge
1 On Wednesday 17 December 2008 22:42:34 Robert Bridge wrote:
2 > On Wed, 17 Dec 2008 15:33:35 -0500
3 >
4 > Willie Wong <wwong@×××××××××.edu> wrote:
5 > > On Wed, Dec 17, 2008 at 08:48:52AM +0000, Mick wrote:
6 > > > On Sunday 14 December 2008, Neil Bothwick wrote:
7 > > > > On Sun, 14 Dec 2008 11:47:51 +0200, Alan McKinnon wrote:
8 > > > > > That's why I suggested them :-) I use them a lot, especially
9 > > > > > when I have to run the same set of commands on 15 different
10 > > > > > hosts, then I do something like:
11 > > > > >
12 > > > > > for I in $(seq 1 15) ; do
13 > > > >
14 > > > > If you're using bash or zsh,you can speed this up with
15 > > > >
16 > > > > for I in {1..15}; do
17 > > >
18 > > > Hmm, I tried this with a sequence of files that look like
19 > > > name0001stat.txt to name0198stat.txt, but when I run {0001..0198}
20 > > > it fails because it seems to ignore the zeros in 0001 and start
21 > > > counting from 1. Do I need to use some escape character for this?
22 > >
23 > > This is one place bash's brace expansion is sorely lacking compared to
24 > > zsh. In this case you need to use the seq command from coreutils. See
25 > > man seq for more info.
26 > >
27 > > In your particular case, you can do
28 > >
29 > > for I in $(seq -w 198); do ... 0$I ; done
30 > >
31 > > seq is more flexible in that it allows arbitrary formatting of the
32 > > sequence using printf floating-point format.
33 >
34 > Or use a wildcard based match.
35 >
36 > name????stat.text works, as would name*stat.text
37
38 <pedantic>
39 name0[01][0-9]{2}stat.text
40 </pedantic>
41
42 would be better still
43
44 --
45 alan dot mckinnon at gmail dot com

Replies

Subject Author
Re: [gentoo-user] [OT] One line script for md5sum Robert Bridge <robert@××××××××.com>