Obinna Nnamani:
Hello, I wrote this grep command to answer this question and it is not returning any output. I have tried this on my system and it works. Is there any thing wrong with the syntax or the problem is from the lab environment?
Alistair Mackay:
Hi @Obinna Nnamani
The expression you have written will only find lines that are a 3 letter word beginning with a capital on its own, as in that 3 letter word is the entire line, because you’re using ^
which matches start of line and $
which matches end of line.
So, it would match the first line here, but not the second. Question is asking for any word (in the whole line).
See
# See `info libc 'NSS Basics'` for more information.
Try
egrep '[A-Z][a-z]{2}' /etc/nsswitch.conf
Obinna Nnamani:
wont egrep ’[A-Z][a-z]{2} match myUseCase?
Obinna Nnamani:
egrep -w '[A-Z][a-z]{2}' /etc/nsswitch.conf
Obinna Nnamani:
this worked. thanks