Gentoo Archives: gentoo-user

From: Drew Tomlinson <drew@××××××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Bash Pattern Matching Syntax
Date: Sat, 15 Oct 2005 23:06:47
Message-Id: 43518A89.9060001@mykitchentable.net
In Reply to: Re: [gentoo-user] Bash Pattern Matching Syntax by Michael Kjorling
1 On 10/15/2005 3:38 PM Michael Kjorling wrote:
2
3 >-----BEGIN PGP SIGNED MESSAGE-----
4 >Hash: SHA1
5 >
6 >On 2005-10-15 15:25 -0700, drew@××××××××××××××.net wrote:
7 >
8 >
9 >>I want to list the files in a directory that end in ".jpg" irregardless of
10 >>case. Thus after reading the bash man page, it seems I should be able to
11 >>issue a command something along the lines of "ls [*.[JjPpGg]]" or "ls
12 >>*.[JjPpGg]" but neither of these work and return a "No such file or
13 >>directory" message. What is the correct syntax for what I'm trying to do?
14 >>
15 >>
16 >
17 >ls *.[jJ][pP][gG]
18 >
19 >Each [] group matches a single character, so "ls *.[JjPpGg]" is "list
20 >all files that end in a period followed by one of J, j, P, p, G or g".
21 >Character ordering is irrelevant.
22 >
23 >Alternatively, you could do:
24 >
25 >ls | grep -i '.jpg$'
26 >
27 >Or:
28 >
29 >find . -maxdepth 1 -iname '*.jpg'
30 >
31 >The find or ls-pipe-grep versions get a LOT cleaner when you have many
32 >known characters with unknown case in the file name, but don't work if
33 >you need to discriminate based on case for some characters and not by
34 >others.
35 >
36
37 Thank you very much for your explanation. This works well!!!
38
39 Cheers,
40
41 Drew
42
43 --
44 Visit The Alchemist's Warehouse
45 Magic Tricks, DVDs, Videos, Books, & More!
46
47 http://www.alchemistswarehouse.com
48
49 --
50 gentoo-user@g.o mailing list