Gentoo Archives: gentoo-user

From: Zhang Weiwu <zhangweiwu@××××××.com>
To: gentoo-user@l.g.o
Cc: skoot@××.pl
Subject: Re: [gentoo-user] [OT] confusing RE doesn't work in diff
Date: Wed, 27 Jul 2005 07:21:01
Message-Id: 1122448118.6628.88.camel@localhost.localdomain
1 Mariusz Pękala wrote:
2 > On 2005-07-25 17:50:37 +0800 (Mon, Jul), Zhang Weiwu wrote:
3 > > > My RE must be wrong but I can hardly successfully match a whole line
4 > > > like the below example:
5 > > >
6 > > > This works:
7 > > > zhangweiwu@Bach:/tmp$ egrep "\b*\/[*].*[*]\/\b*" Calendar.php
8 > > > /* $Id: class.boalarm.inc.php,v 1.1.1.1 2005/03/18 09:17:36
9 > > > dawnlinux Exp $ */
10 > > > /* $Id: class.boalarm.inc.php,v 1.11 2004/05/23 14:51:27
11 > > > ralfbecker Exp $ */
12 > > >
13 > > > This doesn't work:
14 > > > zhangweiwu@Bach:/tmp$ egrep "^\b*\/[*].*[*]\/\b*$" Calendar.php
15 > > >
16 > > > any hint?
17 >
18 > man grep:
19 > The symbol \b matches the empty string at the edge of a word
20 >
21 > It seems that '/' is not considered to be a part of a word.
22 >
23 > I suppose you may use "^[[:space:]]*/[*].*[*]/[[:space:]]*$" Calendar.php
24
25 Thank you! Your RE suggested does work and I discovered this [[:space:]] pretty useful. I missed it in man grep.
26
27 However there is another strange behavor. This works:
28
29 zhangweiwu@Bach:/tmp$ cat header.inc.php
30 <?php
31 /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
32 zhangweiwu@Bach:/tmp$ grep "^[[:space:]]*/[*].*[*]/[[:space:]]*$" header.inc.php
33 /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
34
35 And this doesn't work:
36
37 zhangweiwu@Bach:/tmp$ :>empty
38 zhangweiwu@Bach:/tmp$ diff -I "^[[:space:]]*/[*].*[*]/[[:space:]]*$" header.inc.php empty
39 1,2d0
40 < <?php
41 < /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
42
43 in man it's being said,
44 -I RE --ignore-matching-lines=RE
45 Ignore changes whose lines all match RE.
46
47 I read man grep and it seems there are two sets of RE, extended and basic. But it's not mensioned in diff(1) wheather or not diff(1) takes extended or basic RE. I am using Debian so it should be gnu diff.
48
49 Any thing more to teach me?
50
51 --
52 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] [OT] confusing RE doesn't work in diff Christoph Gysin <cgysin@×××.ch>