On Saturday 24 May 2008, Etaoin Shrdlu wrote: > 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
I am looking for all the scripts with lines like "provide xxx", not just the dns service. That said, your solution did the trick! I amended the expression to: grep -rE '^[[:space:]]+provide[[:space:]]+\w+' /etc/init.d and got what I was after. But why does "[[:space:]]+" work and "\s+" fail? Cheers -Robin -- ------------------------------------------------------ Robin Atwood, Bangkok, Thailand. tel/fax: +66 2252 1438 mobile: +66 851 322487 MSN: [EMAIL PROTECTED] Skype: abend922 Yahoo: abend922 ------------------------------------------------------ -- gentoo-user@lists.gentoo.org mailing list