Issue
I am attempting to delete a line from a text file if it matches a regular expression. To accomplish this I was using sed
in an Ubuntu environment combined with regular expressions. I have tried/referenced the following solutions: Sol1, Sol2, Sol3.
My current command is: sed '/[^"]+},/d' test.json
with this command I am attempting to match and remove lines like:
{"hello},
{"go penguins!},
{"someone help1),
I am NOT trying to match or remove lines like: "should not match regex"},
Any line that ends with "},
should not be deleted.
I am not tied to using sed
so any acceptable answer would work so long as my text file would look something like:
...
{"omg this is amazing"},
{"thanks for your help"},
{"no problem"},
...
Solution
How about sed '/\"},/!d' test.json
?
Answered By - Beta