Gentoo Archives: gentoo-user

From: Willie Wong <wwong@×××××××××.edu>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] One line script for md5sum
Date: Wed, 17 Dec 2008 20:33:57
Message-Id: 20081217203335.GA7337@math.princeton.edu
In Reply to: Re: [gentoo-user] [OT] One line script for md5sum by Mick
1 On Wed, Dec 17, 2008 at 08:48:52AM +0000, Mick wrote:
2 > On Sunday 14 December 2008, Neil Bothwick wrote:
3 > > On Sun, 14 Dec 2008 11:47:51 +0200, Alan McKinnon wrote:
4 > > > That's why I suggested them :-) I use them a lot, especially when I
5 > > > have to run the same set of commands on 15 different hosts, then I do
6 > > > something like:
7 > > >
8 > > > for I in $(seq 1 15) ; do
9 > >
10 > > If you're using bash or zsh,you can speed this up with
11 > >
12 > > for I in {1..15}; do
13 >
14 > Hmm, I tried this with a sequence of files that look like name0001stat.txt to
15 > name0198stat.txt, but when I run {0001..0198} it fails because it seems to
16 > ignore the zeros in 0001 and start counting from 1. Do I need to use some
17 > escape character for this?
18
19 This is one place bash's brace expansion is sorely lacking compared to
20 zsh. In this case you need to use the seq command from coreutils. See
21 man seq for more info.
22
23 In your particular case, you can do
24
25 for I in $(seq -w 198); do ... 0$I ; done
26
27 seq is more flexible in that it allows arbitrary formatting of the
28 sequence using printf floating-point format.
29
30 W
31
32 --
33 Willie W. Wong wwong@××××××××××××××.edu
34 408 Fine Hall, Department of Mathematics, Princeton University, Princeton
35 A mathematician's reputation rests on the number of bad proofs he has given.

Replies

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