Skip to main content
Miscellaneous cleanup.
Source Link

Execute independent greps in a single shell script

I have several grep filters that I usually use to parse specific information.

1st grep:    grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc.

I apply each grep usually to the same file.txt tofile.txt to get aan 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 printsoutputs based on each type of grep.

For example: input file.txtfile.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

or

grep -h -r --color=always "line2\|here2" file.txt >>pattern2.txt

This will highlight only the information required and will give me separate pattern*.txtpattern*.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:

Pattern1

Pattern2

Pattern3

  • Pattern1
  • Pattern2
  • Pattern3

etc.

Each grep should evaluate the completecomplete file independently.

Execute independent greps in a single shell

I have several grep filters that usually use to parse specific information.

1st grep:  grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints 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

or

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:

Pattern1

Pattern2

Pattern3

etc

Each grep should evaluate the complete file independently.

Execute independent greps in a single shell script

I have several grep filters that I usually use to parse specific information.

1st grep:  grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc.

I apply each grep usually to the same file.txt 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

or

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:

  • Pattern1
  • Pattern2
  • Pattern3

etc.

Each grep should evaluate the complete file independently.

Post Reopened by terdon
added 35 characters in body
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

I have several grep filters that usually use to parse specific information.

1st grep: grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints 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

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 patterspatterns.

grep -h -r --color=always "line1\|here1" file.txt >>pattern1.txt

grep -h -r --color=always "line1\|here1" file.txt >>pattern1.txt or grep -h -r --color=always "line2\|here2" file.txt >>pattern2.txt, this

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:

Pattern1

Pattern2

Pattern3

etc

Each grep should evaluate the complete file independently.

I have several grep filters that usually use to parse specific information.

1st grep: grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints 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 patters.

grep -h -r --color=always "line1\|here1" file.txt >>pattern1.txt or 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:

Pattern1

Pattern2

Pattern3

etc

Each grep should evaluate the complete file independently.

I have several grep filters that usually use to parse specific information.

1st grep: grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints 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

or

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:

Pattern1

Pattern2

Pattern3

etc

Each grep should evaluate the complete file independently.

Post Closed as "Needs details or clarity" by Jeff Schaller, Satō Katsura, Archemar, steve, don_crissti
added 762 characters in body
Source Link

I have several grep filters that usually use to parse specific information.

1st grep: grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints 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 patters.

grep -h -r --color=always "line1\|here1" file.txt >>pattern1.txt or 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:

Pattern1

Pattern2

Pattern3

etc

Each grep should evaluate the complete file independently.

I have several grep filters that usually use to parse specific information.

1st grep: grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints based on each type of grep.

I have several grep filters that usually use to parse specific information.

1st grep: grep "pattern1\|pattern2\|pattern3\|" file.txt

2nd grep: grep "patternA\|patternB\|patternC\|" file.txt

etc

I apply each grep usually to the same file.txt to get a independent output.

I would like to know how I can group this bunch of greps into a single bash in order to get independent prints 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 patters.

grep -h -r --color=always "line1\|here1" file.txt >>pattern1.txt or 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:

Pattern1

Pattern2

Pattern3

etc

Each grep should evaluate the complete file independently.

deleted 1 character in body
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719
Loading
Source Link
Loading