- 1

Python: how to search particular word. Which is present in file. And files present in many folder contain same particular wrd

assume main directly is "X" and inside sub directories are "Y" &"Z". and inside text file "input.txt" which contains specific word "seach". I am trying to create scprit which will search specific word "search" and print full line as output even many "search" word present in files. output will come as "result.txt" for both folders.

5th Feb 2018, 6:36 AM
Ashish
3 odpowiedzi
+ 4
I am asking questions, to better understand your needs, but I may not have solutions 😃 I am understanding that you want to: 1. Parse the subdirectories (learn what subdirectories exist) 2. Parse the file names in those subdirectories (know which files exist) 3. Eventually read each of the files in each subdirectory 4. Search the content of each file to see if the keyword is in there 5. Copy line from file which has search keyword to 1 summary file named results.txt Although it may not be as linear as the numbers suggest, that sounds like it sums up your question. Is there 1 of those in particular you need help with?
7th Feb 2018, 6:55 AM
SQrL
SQrL - avatar
+ 3
Does that mean one result.txt will have all files from Y and Z (and any files in X) that have the word found input.txt? Or Y and Z have their own result.txt stored within Y and Z?
6th Feb 2018, 10:27 AM
SQrL
SQrL - avatar
0
yeah result.txt should have all output which is coming from "y" & "z"
6th Feb 2018, 5:31 PM
Ashish