+2 votes
in Operating Systems by (71.8k points)
I want to search a keyword/text in all files in a folder. My goal is to find all the files that contain the specific keyword.What bash command should I use?

1 Answer

+1 vote
by (346k points)
selected by
 
Best answer

You can use 'grep' with the option '-rwl' (force case distinctions) or '-rwli' (ignore case distinctions)

grep -rwl "your_keyword" folder_to_search

OR

grep -rwli "your_keyword" folder_to_search

The meaning of those options are as follows:

-l, --files-with-matches  print only names of FILEs containing matches
-r, --recursive           like --directories=recurse
-w, --word-regexp         force PATTERN to match only whole words
-i, --ignore-case         ignore case distinctions


...