Home > OS >  How to search by key word list in file content for a drive or directory
How to search by key word list in file content for a drive or directory

Time:11-17

I have a text file containing a list of key words. I need to search a drive (and recursively its subfolders) containing millions of files in different formats by those key words in the filename AND their content.

The desired result would be a list of the files containing those keywords and their location.

Is there a way to achieve that with bash or an R script? I was told that bash would be way too slow to execute for that quantity of files, hence I thought about R.

Any suggestions on functions that could achieve that would be appreciated.

CodePudding user response:

I need to search a drive (and recursively its subfolders) containing millions of files in different formats by those key words in the filename AND their content. The desired result would be a list of the files containing those keywords and their location.

Using bash is perfect for this situation.

for item in ($cat file) ; do grep -rni "$item" /search_path ; done

search might take a while tho.

  • Related