Search code examples
shellunixsedvi

How to replace multine values to empty string in linux?


enter image description here

I wanted to change this value

{
"data":"correctValue",
  "attributes": [
    {
      "otherValue": "incorrectValue"
    }
  ]
}

to

{
"data":"correctValue"
}

Solution

  • Or, if instead of deleting the attributes you want to keep .data, you can do:

    jq '{data: .data}' input-file