On Saturday 24 May 2008, 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?

"grep -e" is not the same thing as "egrep" or "grep -E", and
I never managed to get \s to work as a synonym for [[:space:]]
Plus you need a proper file glob i your file spec

Try:
egrep '^[[:space:]]+provide[[:space:]]+\w' /etc/init.d/*

As in:

[EMAIL PROTECTED] /etc/init.d $ 
egrep '^[[:space:]]+provide[[:space:]]+\w' /etc/init.d/*
/etc/init.d/courier-authlib:    provide authdaemond
/etc/init.d/hwclock:    provide clock
/etc/init.d/net.eth0:   provide net
/etc/init.d/net.lo:     provide net
/etc/init.d/net.lo.openrc.bak:  provide net
/etc/init.d/net.wlan0:  provide net
/etc/init.d/postfix:            provide mta
/etc/init.d/shorewall:  provide firewall
/etc/init.d/syslog-ng:  provide logger
/etc/init.d/vixie-cron: provide cron
[EMAIL PROTECTED] /etc/init.d $ 
grep -E '^[[:space:]]+provide[[:space:]]+\w' /etc/init.d/*
/etc/init.d/courier-authlib:    provide authdaemond
/etc/init.d/hwclock:    provide clock
/etc/init.d/net.eth0:   provide net
/etc/init.d/net.lo:     provide net
/etc/init.d/net.lo.openrc.bak:  provide net
/etc/init.d/net.wlan0:  provide net
/etc/init.d/postfix:            provide mta
/etc/init.d/shorewall:  provide firewall
/etc/init.d/syslog-ng:  provide logger
/etc/init.d/vixie-cron: provide cron
[EMAIL PROTECTED] /etc/init.d $ 
grep -e '^[[:space:]]+provide[[:space:]]+\w' /etc/init.d/*
[EMAIL PROTECTED] /etc/init.d $                                                 
                      
-- 
Alan McKinnon
alan dot mckinnon at gmail dot com

-- 
[email protected] mailing list

Reply via email to