Here's an `sh` script that produces the results you need.


    grep -f /path/to/patterns.txt /path/to/*_856_2017* | sort -u > /path/to/foundFiles.txt 

    while read -r LINE
        grep -F "$LINE" /path/to/foundFiles.txt
        if [ $? -eq 1 ]
            echo "$LINE" not found
    done < /path/to/patterns.txt

In this script, I assume you output the results of **your** `grep` to the file `found.txt`, and that you store your patterns in the file `/path/to/foundFiles.txt`.

As you can see, the `grep` in the loop will produce the same contents of the file `found.txt` while adding `"$pattern" not found` for the missing ones.

I also devised a second approach to your case:


    grep -f /path/to/patterns.txt /path/to/*_856_2017* |
        sort -u > /path/to/foundFiles.txt

    comm -23 /path/to/patterns.txt /path/to/foundFiles.txt |
        xargs -L 1 -I {} echo {} not found > /path/to/notFoundFiles.txt

    cat /path/to/foundFiles.txt /path/to/notFoundFiles.txt > /path/to/finalList.txt

In this case, `patterns.txt` needs to be already sorted for `comm` to work.

The `comm` command compares the two files returning the lines present only in `patterns.txt` (`-23` parameter), which is the list of patterns not found by `grep`.

Then, `xargs` grabs every line (`-L 1`) and echoes the line (`{}`) with " not found" appended to it. The result of `xargs` is redirected to the `notFoundFiles.txt` file.

Finally, you simply concatenate foundFiles.txt and notFoundFiles.txt into `finalList.txt`.