I'm trying to grep 3 fields for the strings a, b and c. I know that this can be done with
grep -E 'a|b|c'
However, I also want to grep for the strings x, y and z, including the following line. I know that this can be done with
grep -A1 'x'
So my question is, is it possible to combine all of these into a single command? E.g. something like (i know this command doesn't work, just an example)
grep -E 'a|b|c' -A1 'x|y|z'
If there is a better way without grep, or even using python that would be helpful, I just resorted to using grep as I thought it would be faster than reading a file line by line with python. Cheers!
EDIT: So I have a big file with recurring sections, it looks something like this:
{
    "source_name": [
        "$name"
    ],
    "source_line": [
        52
    ],
    "source_column": [
        1161
    ],
    "source_file": [
        "/somerandomfile"
    ],
    "sink_name": "fwrite",
    "sink_line": 55,
    "sink_column": 1290,
    "sink_file": "/somerandomfile",
    "vuln_name": "vuln",
    "vuln_cwe": "CWE_862",
    "vuln_id": "17d99d109da8d533428f61c430d19054c745917d0300b8f83db4381b8d649d83",
    "vuln_type": "taint-style"
}                      
And this section between the {} repeats in the file. So what I'm trying to grep is the line below source_name, source_line and source_file along with the vuln_name, sink_file and sink_line. So sample Output should be:
    "source_name": [
        "$name"
    "source_line": [
        52
    "source_file": [
        "/somerandomfile"
    "sink_line": 55,
    "sink_file": "/somerandomfile",
    "vuln_name": "vuln",
    
grep -Poz 'a|b|c|(x|y|z).*\R.*' file