I found the following awk script in a previous answer for splitting large files into smaller parts based on a pattern (replacing header-line with a different pattern).  However, I have the need to take it even further as there could be millions of parts created but if I can filter each one again it will get what I need.awk '    /header-line/ {++part}    {print >sprintf(part-%03d.txt, part)}'Is it possible to interrogate each part either before or after it is written to check if a certain pattern exists in the part and only write that part out on a match for the additional pattern.As an example, The initial criteria would be ID:  (the header-line above). I then want to search each part created for a particular method name; call it searchForThisMethod as the string to search for which could be at various locations in the part. Example Input:ID: 1bbbbbbbbsecondaryCheckID: 2bbbbbbbbID: 3hhhhhsecondaryCheckgggg
Split file by pattern keeping only the pieces that contain a second pattern
text processing;awk