AWK/SED appending to log file
<p>I have a qpid command that run and it gives me a pretty print for mat like so:</p>

<pre><code>{
"value": {
    "application": {
        "connectionState": "Disconnected",
        "connectionTime": "No connection was established",
        "linkAttributes": {
            "ackSettings": {
                "dataAckEnabled": "true",
                "dataAckTimeout": "5000",
                "dataNakRetryLimit": "0",
                "retransmitDelay": "500"
            },
            "keepAliveSettings": {
                "keepAliveAckTimeout": "5000",
                "keepAliveInterval": "30000"
            },
            "logTraffic": "false",
            "port": "9999",
            "role": "server"
        },
        "protocol": "Class"
    }
},
"queueStats": {}
</code></pre>

<p>I take this output and strip the quitation marks as well as the brackets then I append it to a log file with the command below:</p>

<pre><code>command | sed 's/"//g'  | sed 's/{//g' | sed 's/}//g' | sed -e 's/$/\r/g' |awk '!/""/{ORS=(/},/?RS:""); gsub(/[[:blank:]]+/,""); sub(/}$/,"},\n"); print}' |awk '{gsub(/\\n/,"\n")}1' &gt;&gt; app.log
</code></pre>

<p>The result is the following:</p>

<pre><code>  ^M^M^MendpointApplications:^MApplicationSide:^MconnectionState:Disconnected,^MconnectionTime:Noconnectionwasestablished,^MlinkAttributes:^MackSettings:^MdataAckEnabled:true,^MdataAckTimeout:5000,^MdataNakRetryLimit:0,^MretransmitDelay:500^M,^MkeepAliveSettings:^MkeepAliveAckTimeout:5000,^MkeepAliveInterval:30000^M,^MlogTraffic:false,^Mport:9999,^Mrole:server^M,^Mprotocol:ClassD^M^M,^MqueueStats:^M
</code></pre>

<p>How do I get rid of the ^M characters each time I want to append the output to the log in a new line?</p>

<p>My expected result would be:</p>

<pre><code>    endpointApplications:ApplicationSide:connectionState:Disconnected,connectionTime:Noconnectionwasestablished,linkAttributes:ackSettings:dataAckEnabled:true,dataAckTimeout:5000,dataNakRetryLimit:0,retransmitDelay:500,keepAliveSettings:keepAliveAckTimeout:5000,keepAliveInterval:30000,logTraffic:false,port:9999,role:server,protocol:ClassD,queueStats:
</code></pre>

<p>Basically,same result as before but without ^M characters, I would like to append the result of the command onto a new lime each time. </p>