I am trying to extract a substring after matching a pattern in a string.
Now I can't share my hole file but let's take this example.
From this string:
{"code":"S02A5","name":"18\" Leichtmetallräder Doppelspeiche 397","price":"0","standard":"false"}
I want to extract this substring
18\" Leichtmetallräder Doppelspeiche 397
So far I tried the following :
This matches to many results
grep -oP '(?<="code":".....","name":")[^"]+'
I know that the first char after "name":" is always 1, so I tried to use this in the following command, and the return is 8\ which is not that bad because I can add the 1 afterwards.
grep -oP '(?<="code":".....","name":"1)[^"]+'
The problem is that I can't find a way to retrieve the rest of the substring needed, because there's an extra quotation mark after that backslash.
Any ideas how can I solve this?
jqfor handling structured, formatted data like JSON. Usinggrepto do it is like stirring paint with a screwdriver.