How to find a word inside a folder recursively in linux?

This can be done using grep command.

If you are searching in current directory use dot(.) as shown below

Options we have used

  • -n                   : Show relative line number in the file
  • -r                    :  Recursively search subdirectories listed
  • ‘searchString’ :  String for search
  • /yourdirectory : Directory for search

Example

The above command will search for hello. So the output would be like
./first.log:70: My say hello and ….
./subdir/second.log:70: The hellolite app was used ..

To check more parameters use man grep command.

T Tak

Hey ! I'm Tak. I'm a software developer since 2008 and been programming since I was 17 years, started with pascal. I love programming, teaching and building stuff on web.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.