1 |
On Saturday 24 May 2008, Etaoin Shrdlu wrote: |
2 |
> On Saturday 24 May 2008, 17:22, Robin Atwood wrote: |
3 |
> > Regexs are not my strong point! I am trying to get a list of service |
4 |
> > scripts that provide virtual services. Each such script contains a |
5 |
> > line like: |
6 |
> > |
7 |
> > provide dns |
8 |
> > |
9 |
> > i.e. the line starts with one or more spaces, followed by the text |
10 |
> > "provide", followed by one or more spaces and a single word. i have |
11 |
> > come up with: |
12 |
> > |
13 |
> > grep -e ^\s+provide\s+\w /etc/init.d |
14 |
> > |
15 |
> > but, as usual, nothing is matched. What am I doing wrong? |
16 |
> |
17 |
> On my system, no initscript has the line "provide dns" in it, so it might |
18 |
> be possible that you don't have any file with that line. |
19 |
> |
20 |
> That said, you should use -r, and you don't need the -e switch: |
21 |
> |
22 |
> grep -r '^[[:space:]]\{1,\}provide[[:space:]]\{1,\}dns' /etc/init.d |
23 |
> |
24 |
> or, perhaps clearer |
25 |
> |
26 |
> grep -rE '^[[:space:]]+provide[[:space:]]+dns' /etc/init.d |
27 |
|
28 |
I am looking for all the scripts with lines like "provide xxx", not just the |
29 |
dns service. That said, your solution did the trick! I amended the expression |
30 |
to: |
31 |
|
32 |
grep -rE '^[[:space:]]+provide[[:space:]]+\w+' /etc/init.d |
33 |
|
34 |
and got what I was after. But why does "[[:space:]]+" work and "\s+" fail? |
35 |
|
36 |
Cheers |
37 |
-Robin |
38 |
-- |
39 |
------------------------------------------------------ |
40 |
Robin Atwood, Bangkok, Thailand. |
41 |
tel/fax: +66 2252 1438 |
42 |
mobile: +66 851 322487 |
43 |
MSN: robin@×××××.org |
44 |
Skype: abend922 |
45 |
Yahoo: abend922 |
46 |
------------------------------------------------------ |
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
-- |
59 |
gentoo-user@l.g.o mailing list |