I'm searching for two patterns from very large files and I don't want to grep more than once. I'm currently running this command to look for the patter, then if found also take the one line before and two lines after the line with the match, then remove the line separators with sed, and finally zip the output:
zgrep -B 1 -A 2 'Pattern_1' In.gz | sed '/^--$/d' | gzip >out.gz
How could I look for both pattern 1 and 2 simultaneously and print my lines to out1.gz or out2.gz, respectively. I read this thread but I'm not familiar with awk so I'm not sure if it applies to my situation.