1

I have a large potentially zipped log file and I can identify which line number some text I'm interested in is on using:

find . -name "*" -exec zgrep -C 1 -n -i -H TextToFind {} \;

But in a second command I'd like to look for the full message between two known values that contain the line number I'm interested in. The text I want is between an open and close "Execute" and exists thousands of times in the file but I only want to return the open and close execute block that contains a specific line number.

For example if I searched for Wiggam thru a large document that contained multiple bunchoftext I want to just see content of the executes that contain the text to match.

Sample input is a bunch of the following that do not match the search string anywhere, sample output would be:

took (937) millis, success (true), payload [ Requests Target firstname Ralph lastname Wiggam 00000000-0000-0000-0000-000000000000 contact 78542154-5541-741f-7474-987654321654 Create Settings false true 32423421-4341-654f-34834983489734987 ExecuteMultiple ]

took (937) millis, success (true), payload [ Requests Target firstname Ralph lastname Wiggam

                                </b:Attributes>
                                <b:EntityState i:nil="true"/>
                                <b:FormattedValues/>
                                <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
                                <b:KeyAttributes xmlns:d="http://schemas.microsoft.com/xrm/7.1/Contracts"/>
                                <b:LogicalName>contact</b:LogicalName>
                                <b:RelatedEntities/>
                                <b:RowVersion i:nil="true"/>
                            </c:value>
                        </b:KeyValuePairOfstringanyType>
                    </b:Parameters>
                    <RequestId xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">98765431-1473-4742-874e-564875211265</RequestId>
                    <b:RequestName>Create</b:RequestName>
                </d:OrganizationRequest>
            </c:value>
        </b:KeyValuePairOfstringanyType>
        <b:KeyValuePairOfstringanyType>
            <c:key>Settings</c:key>
            <c:value i:type="d:ExecuteMultipleSettings">
                <d:ContinueOnError>false</d:ContinueOnError>
                <d:ReturnResponses>true</d:ReturnResponses>
            </c:value>
        </b:KeyValuePairOfstringanyType>
    </b:Parameters>
    <RequestId xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">78797845-4543-7841-78454315487464545</RequestId>
    <b:RequestName>ExecuteMultiple</b:RequestName>
</request>

]

How can I do this?

  • Can you post an example of the text and what you expect as ouput? – schrodigerscatcuriosity Oct 25 '19 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.