+2 votes
in Operating Systems by (15.3k 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

0 votes
by (27.1k points)

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

grep -rwl "your_keyword" folder_to_search


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