grep -oP quickly filter out the weblogic instance name

Scenario: Xiao Zhang is in charge of weblogic. Every time you log in to the server to view the weblogic instance name, you must first see a bunch of information when you use the ps -ef |grep weblogic command, and then find the information you want to view from the bunch of information , Is too inconvenient. Later, Xiao Zhang studied the grep regularity and finally solved this problem. The command is as follows:
#ps -ef | grep -oP'(?<=\WDweblogic\WName\W)\S+'
Parameter description:
-o displays the matched characters String
-P for regular matching
(?<=): backward matching, here is that the (?<=) brackets must have a fixed length, such as matching'-Dweblogic.Name=', here is'\WDweblogic\WName\ W'can also be written as' (?<=\W\S{9}\WName\W)\S+'.
When using ps -ef |grep weblogic, the following information appears:
grep -oP quickly filter out the weblogic instance name

After using ps -ef | grep -oP'(?<=\WDweblogic\WName\W)\S+', the following information appears:
grep -oP quickly filter out the weblogic instance name

In comparison, it is much more concise and convenient.

Guess you like

Origin blog.51cto.com/14483703/2540572