Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
    Post Closed as "unclear what you're asking" by Scott, HalosGhost, sam, Anthon, GAD3R
4 added 10 characters in body
source | link

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input
001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna: ^001 patternb: 600: sometext

the output would be a file named 600: sometext.txt

001 876786 
600: sometext
001 712345 
600: sometext
001 5342 
600: sometext
001 987   
600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input
001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna ^001 patternb 600: sometext

the output would be a file named 600: sometext.txt

001 876786 600: sometext
001 712345 600: sometext
001 5342 600: sometext
001 987  600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input
001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna: ^001 patternb: 600: sometext

the output would be a file named 600: sometext.txt

001 876786 
600: sometext
001 712345 
600: sometext
001 5342 
600: sometext
001 987 
600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

3 added 2 characters in body
source | link

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input 
001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna ^001 patternb 600: sometext

the output would be a file named 600: sometext.txt

001 876786 600: sometext
001 712345 600: sometext
001 5342 600: sometext
001 987 600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input 001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna ^001 patternb 600: sometext

the output would be a file named 600: sometext.txt

001 876786 600: sometext
001 712345 600: sometext
001 5342 600: sometext
001 987 600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input 
001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna ^001 patternb 600: sometext

the output would be a file named 600: sometext.txt

001 876786 600: sometext
001 712345 600: sometext
001 5342 600: sometext
001 987 600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

2 added 881 characters in body
source | link

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input 001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna ^001 patternb 600: sometext

the output would be a file named 600: sometext.txt

001 876786 600: sometext
001 712345 600: sometext
001 5342 600: sometext
001 987 600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

a) i have one huge file, from which i need to extract all the lines that match specific patterns, letus say paterna and patternb. So i need to extract all lines that start with patterna something like ^patterna, and all lines, that start with patternb something like ^patternb. Then write the output to a file named patternapatternb.txt

b) how could i make this work with a loop. For example, do the same for patterna2 and patternb2, then do the same with patterna3 and patternb3, so the file will be parsed many times, with new pairs of patterns to match lines each time, and finally the output then would be three files:

patternapatternb.txt
patterna2patternb2.txt
patterna3patternb3.txt

sample input 001 876786
989 74563
734 87387


600: sometext
601: someothertext

001 712345
345 87238


600: sometext
702: differenttext

001 5342
989 745632
734 873872


600: sometext
601: someothertext

001 987 345 87238


600: sometext
702: differenttext

patterna ^001 patternb 600: sometext

the output would be a file named 600: sometext.txt

001 876786 600: sometext
001 712345 600: sometext
001 5342 600: sometext
001 987 600: sometext

Actually, the first element in the pair of patterns, will be the ^001, and the second, each occurrence of a line that starts with three digits, followed by a :, then a space

1
source | link