Showing posts with label grep. Show all posts
Showing posts with label grep. Show all posts

Wednesday, December 1, 2010

Grep with filenames

Sometimes you want grep to tell you what files have a pattern within a directory.  Here is how to do it:


grep -H JAVA_HOME=/  /usr/local/terracotta/bin/* /usr/local/terracotta/platform/bin/*

/usr/local/terracotta/bin/start-tc-server.sh:export JAVA_HOME=/usr/java/jdk1.6.0_21/
/usr/local/bin/stop-tc-server.sh:export JAVA_HOME=/usr/java/jdk1.6.0_21/
/usr/local/bin/tim-get.sh:export JAVA_HOME=/usr/java/jdk1.6.0_21/
/usr/local/platform/bin/make-boot-jar.sh:export JAVA_HOME=/usr/java/jdk1.6.0_21/


Enjoy!

Thursday, July 8, 2010

Killing zombie processes

Kill those persistent and annoying zombie processes.


ps -e -o ppid,stat | grep Z | cut -d" " -f2 | xargs kill -9

Tested on Fedora for accuracy.  

Thursday, June 17, 2010

Find the PID number with nothing else

Use this combination to find a PID number without anything else in the output:

ps -ef | grep -v grep | grep ssh | cut -d" " -f3
3012

Enjoy that kungfu knife-kick combo.

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.