I need to find all strings, which contain <some_word>. There is MAIN directory, where we have to search and there can be files and other directroies (with files). It must enter one directory – check all files there for <some_word>, return to main directory – enter another directroy – check all files there, return to main directory… and so on and so for. I have no problems to make this, when there are only files in main directory… but don’t know how to make it with directories… please help me.
I need to find all strings, which contain <some_word> . There is MAIN directory,
Share
To process all files in a directory:
For more information, see the documentation for
Dir.[]orDir.glob.Thus, if you already have
find_text_in_file( some_word, filepath )you can do:Note that the above will search the files in a depth-first traversal. If you want to search in a breadth-first manner you can instead use this:
Alternatively, if you already have
find_word_in_directory( some_word, dirpath )then you can do: