grep next exact match in double quotes

0

I am trying to grep string and next string which is marked in double quotes.

Its a .xml file and the content would be as below:

<jvmEntries xmi:id="1183122130078" verboseModeClass="false" verboseModeGarbageCollection="true" verboseModeJNI="false" initialHeapSize="512" maximumHeapSize="1024" runHProf="false" hprofArguments="" debugMode="false" debugArgs="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n" genericJvmArguments="-Xinitsh4m -Xk30000">

So, I am trying to grep as below out of above content. I mean to grep the match string as well as the preceeding string.

initialHeapSize="512"

maximumHeapSize="1024"

debugArgs="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"

I tried these:

grep -o 'initialHeapSize=......' server.xml

grep -o 'maximumHeapSize=......' server.xml

grep -o 'debugMode=.......' server.xml

But the problem is with the string in double quotes which may be long like for debugArgs. Should be able to grep any case(upper or lower case) and = should not cause issue while grep.

Any suggestions

Thanks

user2692634

Posted 2014-01-21T07:34:41.377

Reputation: 29

Answers

0

What about:

grep -o 'debugArgs=\"[[:punct:][:alnum:]]*\"' server.xml

fede.evol

Posted 2014-01-21T07:34:41.377

Reputation: 1 718