Trick on grep
Normally every WebLogic user/Admin knows that "ps -ef|grep java" gives you the WebLogic servers process list in any UNIX or Linux environments. Most of the forums suggesting use "|grep -v" to exclude the "grep line". But, here I don't want to use one more pipe and grep -v option really makes expensive in CPU cycles. Searched for the optimistic solutions and finally found! Two choices using --exclude and using regex.
The exclude options is not available on all UNIX systems. So I've chosen next option.
How do you avoid the grep line in the grep command output itself?
Here the trick is using the regular expression to workout this requirement. Use your searching pattern any one of the character in [] then it will automatically excludes the grep line from the output. actually it wouldn't get output itself!
bash-2.05$ ps -ef |grep jav[a]:none
weblogic 950 934 0 Feb 10 ? 0:06 /usr/local/bea/jdk142_11/bin/java -client -Xms32m -Xmx200m -Xverify
Note here I have tried out this trick on Sun Solaris 9 machine. Write your experiments in the comment box, share it!
No comments:
Post a Comment