I have a logfile with multiple lines like "DEBUG MDM payload:" and on separate lines after that is the xml content which can differ in lenght but always ends the same. How can i user tr and sed or another method to combine all the xml content on the same line as "DEBUG MDM payload:"?
2017-01-26T10:54:28.712+0100 - CORE {wff-device-thread-15 : deviceRestExecuteWorkflow.deviceRestExecuteActivity.EventQueueConsumer} device.ios.management|logger [{{Correlation,dhdjwdw-3a44-4b0d-aa52-dwdwdwdwdw}{Uri,PUT /S29112264/ios/mdm2/dwdwdwdw-c7d2-465c-be44-dwdwdwdw}{host,de0-server.name.fqdn}}] - DEBUG MDM payload:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Command</key>
<string>dd2c2a59-2007-4863-9c8c-dgfhgfh666666</string>
<key>command</key>
<dict/>
<key>Status</key>
<string>Approved</string>
<key>UDID</key>
<string>90f0c56287474782748274827487842cc64c2fc4</string>
</dict>
</plist>
Update: The following command will print what i want just cant figure out how to take that and alter the file to put it on one line.
sed -n "/\/ios\/mdm2\DEBUG MDM payload/,/<\/plist>/p"
Update 2: Ok bit further now but i still have some tabs in some cases. trying to find a way to remove tabs next.
sed -n "/DEBUG MDM payload/,/<\/plist>/p" fake_log.txt | tr -d "\r" | tr -d "\n"
Update 3: OK, got it. Now is there a way to remove the existing lines and have this newly modified line added in its place?
sed -n "/DEBUG MDM payload/,/<\/plist>/p" fake_log.txt | tr -d "\r" | tr -d "\n" | tr -d "\t"