0

I have the following logs (removed unnecessary info) :

Feb 18 11:38:54 Kingston dhcpd: DHCPACK
Feb 18 11:39:01 duxbury /USR/SBIN/CRON[27892]:
Feb 18 17:39:01 ruby /USR/SBIN/CRON[13080]: 

How Can I grep for a server name (kingston, ruby or duxbury) while ensuring that date/time info is next to the server name? so for instance I could grep for kingston, and it would return "Feb 18 11:38:54 Kingston dhcpd: DHCPACK" but if only "some data Kingston" (no date/time info) was available, then nothing would be returned. Thanks for the help!

1 Answer 1

2
grep -E "^[a-zA-Z]+ [0-9]+ [0-9]+:[0-9]+:[0-9]+ Kingston"
1
  • This should either use egrep ... or grep -E ....
    – Thor
    Feb 18, 2013 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.