I have list of file in directory:
gp_dump_0_10_20171112003450 <==
gp_dump_0_11_20171112003450 <==
gp_dump_0_12_20171112003450 <==
gp_dump_0_13_20171112003450 <==
gp_dump_0_14_20171112003450 <==
gp_dump_1_1_20171112003450 <==
gp_dump_1_1_20171112003450_post_data
gp_dump_20171112003450_ao_state_file
gp_dump_20171112003450_co_state_file
gp_dump_20171112003450_last_operation
gp_dump_20171112003450.rpt
I want to fetch only marked ( <==) files from a directory. Below is the python code I have written which is not working as expected:
import os
import re
dump_key = 20171112003450
backup_files = os.listdir('/home/jadhavy/backup/')
segment_file_regex = "gp_dump_\d+?_\d+?_%s$" %dump_key
for file in backup_files:
if file == re.finditer(segment_file_regex,file,re.S):
print(file)
EDIT:Changed regex to match end, I'm not getting any result after running this.