How to grep lines between two patterns in a big file with python
问题 I have a very big file, like this: [PATTERN1] line1 line2 line3 ... ... [END PATTERN] [PATTERN2] line1 line2 ... ... [END PATTERN] I need to extract in another file, lines between a variable starter pattern [PATTERN1] and another define pattern [END PATTERN], only for some specific starter pattern. For example: [PATTERN2] line1 line2 ... ... [END PATTERN] I already do the same thing, with a smaller file, using this code: FILE=open('myfile').readlines() newfile=[] for n in name_list: A = FILE[