I have several grep filters that I usually use to parse specific information.
grep "pattern1\|pattern2\|pattern3\|" file.txt
grep "patternA\|patternB\|patternC\|" file.txt
I apply each grep usually to the same
to get an independent output.
I would like to know how I can group this bunch of greps into a single bash script in order to get independent outputs based on each type of grep.
For example: input
file.txt looks as follows:
This line1 is the first line in here1 This line2 is the second line in here2 This line3 is the third line in here3 This line4 is the fourth line in here4
I usually apply separate greps here to get specific patterns.
grep -h -r --color=always "line1\|here1" file.txt >>pattern1.txt
grep -h -r --color=always "line2\|here2" file.txt >>pattern2.txt
This will highlight only the information required and will give me separate
pattern*.txt files to work on. The objective here is to run all these greps in a single time to evaluate the same file and print in shell as follows:
Each grep should evaluate the complete file independently.