0

I have a file where each line is a JSON object:

{"index":{}}
{"msg_text":"yes","@timestamp":"2019-03-31T00:01:59.574Z","o_error":"INTERNAL_INVALID_MESSAGE","sender":"353830465174","account_id":"e15965cf-ffc1-40ae-94c4-b450ab190222","recipient":"49223","@version":1,"submission_ts":1553990519574000,"delivery_ts":1553990519574000}
{"index":{}}
{"msg_text":"yes","@timestamp":"2019-03-31T00:01:59.574Z","o_error":"INTERNAL_INVALID_MESSAGE","sender":"353830478555","account_id":"e15965cf-ffc1-40ae-94c4-b450ab190222","recipient":"49223","@version":1,"submission_ts":1553990519574000,"delivery_ts":1553990519575000}
{"index":{}}

I want to remove all the delivery_ts fields and values. So the following is what I want:

{"index":{}}
{"msg_text":"yes","@timestamp":"2019-03-31T00:01:59.574Z","o_error":"INTERNAL_INVALID_MESSAGE","sender":"353830465174","account_id":"e15965cf-ffc1-40ae-94c4-b450ab190222","recipient":"49223","@version":1,"submission_ts":1553990519574000}
{"index":{}}
{"msg_text":"yes","@timestamp":"2019-03-31T00:01:59.574Z","o_error":"INTERNAL_INVALID_MESSAGE","sender":"353830478555","account_id":"e15965cf-ffc1-40ae-94c4-b450ab190222","recipient":"49223","@version":1,"submission_ts":1553990519574000}
{"index":{}}

How can I do this using Linux commands?

1 Answer 1

1

Editing JSON is what jq exists to do.

jq -c 'del(.delivery_ts)' <in.json >out.json

See this running against your stated input at https://jqplay.org/s/v1-J5cTMA-

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.