Grep is one of the most useful commands. You can use grep on any UNIX-based operating system, and you can even get grep for Windows. When I'm stuck in Windows, I use use grep inside of Cygwin.
The syntax for grep is:
grep [options] PATTERN [FILE...]Commonly used options are:
There are many more options than the common ones I've listed above. Type man grep in the terminal for a complete list.
To search a log file for every line that contains Googlebot and write to a file called google_access.log, you could use this:
grep Googlebot access.log > google_access.logThe following example of grep takes a logfile that only has hits from Googlebot and removes all of the requests for .png files.
grep -v \.png google_access.log > google_access_no_pngs.log Did you find this post helpful? Leave a comment below, and subscribe to my RSS feed.