Question

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!

Was it helpful?

Solution

grep -E "^[a-zA-Z]+ [0-9]+ [0-9]+:[0-9]+:[0-9]+ Kingston"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top