So, the bash command that I'd be normally using in a Bash Script would be something like:
$ cat huge2GBfile.txt | grep -w "pattern1/|pattern2/|pattern3" > out.txt
It will output the lines in huge2GBfile where it has found pattern1,2,3. I was wondering if this is achievable through python. I know that I can use
os.system(cmd)
But I'd like to know if there is something similar in Python (I am a complete noob) and if it is faster than using cat+grep. Thanks!
Initial thoughts, would something like
for line in f:
if pattern in line:
out.write(line)
be faster?