How Do I Grep a Word in Multiple Directories in Linux?
Contents

How do you grep words in multiple folders?

To include all subdirectories in a search, add the -r operator to the grep command. This command prints the matches for all files in the current directory, subdirectories, and the exact path with the filename.

How do you grep a word in multiple directories in UNIX?

To recursively search using grep , use the -R option. To search for an exact string, use -F , so that 2* isn’t treated as a regular expression.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest