I have a huge file (1/2 million lines) of json.
I need to delete a set of entries that contain a certain string.
{
"bla1": {
"Part1": "Plop1",
"Part2": "Plop2",
"Part3": "BadFling1<stuff>",
"part4": "Plop4",
},
"bla2": {
"Part1": "Plop1",
"Part2": "Plop2",
"Part3": "<stuff>",
"part4": "Plop4",
},
// etc for many more entries
}
All the entries have "BadFling1" as the prefix to the "Part3" entry.
I was wondering how the best way to automate removing all entries that include "BadFling1". So for example the result of removing the bad entry from above is:
{
"bla2": {
"Part1": "Plop1",
"Part2": "Plop2",
"Part3": "<stuff>",
"part4": "Plop4",
},
// etc for many more entries
}
My first attempt was working but not fast enough (as it was slightly manual).
/BadFling1
qan3k5ddq
:map z n@a
Now hold down the 'z' key.
My vim foo is not strong enough, so I am unsure how to automate the processes better in vim. Any help appreciated.
Alternative approaches in bash (or other command line tools also welcome).
underscore
package (npm install underscore
) with an appropriateselect
command (has command-line interface, see jsonselect.org for syntax)? It is better to use a chisel than a hammer when a chisel is available. – Deer Hunter Dec 18 '12 at 9:07