I have a file with text like following:
{name: "Jon", kids: [{i: 1, n: "tyrell"}, {i: 2, n: "angela"}, {i: 3, n: "elliot"}]
what I want to achieve is delete every string with ":i" so in this case it would look like this
{name: "Jon", kids: [{n: "tyrell"}, {n: "angela"}, {n: "elliot"}]
so if there is a "i:" it should delete everything (including the i:) up to the comma ","
How could I achieve something like this?
Given
then
Add
-i
or--in-place
to overwrite the contents of the original fileHowever if your file contains structured data you should use the right tools for the job - yours looks almost like JSON aside from the unquoted keys and missing terminating brace:
This one does what you ask for,
This one does what you show (removes the space after the comma),
What you want in the real case is to run
sed
with an input fileand probably redirect to an output file