Gentoo Archives: gentoo-user

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

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] [OT] One line script for md5sum Alan McKinnon <alan.mckinnon@×××××.com>