Reputation: 1011
Inside a text file, I want to find any line containing 4294967295
<DVAMarker>{"DVAMarker":{"mCuePointList":[{"mKey":"marker_guid","mValue":"4e469eea-d7a9-49e8-b034-a4001272ddfb"},{"mKey":"keywordExtDVAv1_87b5cf3c-5b50-4ceb-8ae4-0978c58d3775","mValue":"{\"color\":4294967295}"}],"mDuration":{"ticks":3911846400000},"mMarkerID":"9c6d9e19-3790-4e25-bd3f-8808f1ce73ea","mName":"Montenegro","mStartTime":{"ticks":88062266880000},"mType":"Comment"}}</DVAMarker>
Then insert mComment":"BLUE", before "mCuePointList", so the result would look like
<DVAMarker>{"DVAMarker":{mComment":"BLUE", "mCuePointList":[{"mKey":"marker_guid","mValue":"4e469eea-d7a9-49e8-b034-a4001272ddfb"},{"mKey":"keywordExtDVAv1_87b5cf3c-5b50-4ceb-8ae4-0978c58d3775","mValue":"{\"color\":4294967295}"}],"mDuration":{"ticks":3911846400000},"mMarkerID":"9c6d9e19-3790-4e25-bd3f-8808f1ce73ea","mName":"Montenegro","mStartTime":{"ticks":88062266880000},"mType":"Comment"}}</DVAMarker>
I am using bash and gawk in Terminal on a mac.
Upvotes: 0
Views: 68
Reputation: 133428
I am not sure if this is a json or xml(doesn't look to me, though I am not an expert in it), with awk
if you could try following.
awk '/4294967295/{sub(/"mCuePointList"/,"mComment\":\"BLUE\",&")} 1' Input_file
Upvotes: 3