Similar question to alternative of “grep” in python; but the complexity here is what is grepped is variable (lines) from another file. I cannot figure out how to do this using functions like re.findall()
file1:
1 20 200
1 30 300
file2:
1 20 200 0.1 0.5
1 20 200 0.3 0.1
1 30 300 0.2 0.6
1 40 400 0.9 0.6
2 50 300 0.5 0.7
Each line from file1 is my pattern; and I need to search such pattern from file2.
Then result should be:
1 20 200 0.1 0.5
1 20 200 0.3 0.1
1 30 300 0.2 0.6
I’ve been trying to solve the problem using either bash or python,but cannot figure out.
thx
Here’s a non-regex based solution: