Gentoo Archives: gentoo-user

From: Willie Wong <wwong@×××××××××.EDU>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] About sed
Date: Mon, 07 Nov 2005 04:12:50
Message-Id: 20051107040741.GC31348@princeton.edu
In Reply to: [gentoo-user] About sed by Rafael Barreto
1 On Mon, Nov 07, 2005 at 01:44:42AM -0200, Rafael Barreto wrote:
2 > Hi,
3 >
4 > I'm learning about the use of the sed command and I have some questions. I'm
5 > trying to read in /etc/conf.d/clock the CLOCK variable with:
6 >
7 > sed '/^CLOCK="*"$/p' /etc/conf.d/clock
8 >
9 > This command, in principe, must print in screen the line that contains
10 > CLOCK= in the begin, contains anything between double quotes and ends. Well,
11 > this doesn't return anything. If I enter the above command without $, all is
12 > ok. But, if I would like to return just that line contains CLOCK="anything"
13 > and nothing more? For example,
14
15 No it doesn't. What you want is the regexp ^CLOCK=".*"$ if you want
16 anything (including nothing) between the double quotes, or
17 ^CLOCK=".+"$ if you want something (excluding nothing) between the
18 double quotes.
19
20 The reason that removing the trailing $ worked is that it matched the
21 CLOCK=" part, the * character specifies 0 or more iterates of the
22 previous character, which is "
23
24 HTH
25
26 W
27 --
28 Q: Why won't Heisenberg's operators live in the suburbs?
29 A: They don't commute.
30 Sortir en Pantoufles: up 4 days, 5:24
31 --
32 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] About sed Rafael Barreto <rafaelmbarreto@×××××.com>
Re: [gentoo-user] About sed gentuxx <gentuxx@×××××.com>