Showing posts with label Splunk. Show all posts
Showing posts with label Splunk. Show all posts

Tuesday, March 31, 2009

Grep entire directories

To find a phrase that could be found somewhere in the current directory, use the command:

grep -r -i searchString ./

For example:

grep -r -i splunk /etc

This would search the entire /etc filesystem for any line with the word "splunk" located therein. Another way to do this would be the command:

find / -type f -print | xargs grep splunk

It works well with HP-UX and other Unixes.

Thursday, March 26, 2009

Tar with date and a twist of chocolate

Here is a way to tar up a set of important directories with the date. You can use this as a log archive, or with Splunk. This uses the highest compression of gzip (-9).

tar cp /myapp/logs /var/log/messages /var/log/httpd/ | gzip -9c > /tmp/oldlogs`date +"%Y%m%d"`.tgz