I have a lookup file (file1.txt) which has a list of patterns to be searched.
Ex content of file1.txt
dtdge_ddgaec
daew_e2
I have to list out the files in a particular directory based on the pattern in file1.txt Ex: If a particular directory has the below-mentioned files
abdc_dtdge_ddgaec_09030.txt
odad_dwad_dadatge_daece_0869.txt
dadaf_dawa_dpidae_daew_e2_0901.txt
adydyaq_da9dad_dagda_dadge_0730.txt
I need to display only the files that match the pattern in file1.txt
Output:
abdc_dtdge_ddgaec_09030.txt
dadaf_dawa_dpidae_daew_e2_0901.txt
In Unix Scripting, I can read file1.txt line by line and using ls command i can match the pattern using grep command and display the desired output.
I'm new to Python and unable to find an easy solution. Can anyone help me with this?