On Saturday 24 May 2008, 17:22, Robin Atwood wrote:

> Regexs are not my strong point! I am trying to get a list of service
> scripts that provide virtual services. Each such script contains a
> line like:
>
>       provide dns
>
> i.e. the line starts with one or more spaces, followed by the text
> "provide", followed by one or more spaces and a single word. i have
> come up with:
>
>        grep -e ^\s+provide\s+\w /etc/init.d
>
> but, as usual, nothing is matched. What am I doing wrong?

On my system, no initscript has the line "provide dns" in it, so it might 
be possible that you don't have any file with that line.

That said, you should use -r, and you don't need the -e switch:

grep -r '^[[:space:]]\{1,\}provide[[:space:]]\{1,\}dns' /etc/init.d

or, perhaps clearer

grep -rE '^[[:space:]]+provide[[:space:]]+dns' /etc/init.d
-- 
[email protected] mailing list

Reply via email to