Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the files recursively having a text pattern excluding some directories and files [duplicate]

Tags:

bash

shell

sh

How to find the files recursively having a text pattern excluding some directories and files?

Example:- 
$ ls
bower.json      bower_components    configure       results         unit-tests

so I need to find "searchText" recursively in all directories excluding bower.json and results

like image 547
nagendra547 Avatar asked Aug 04 '17 06:08

nagendra547


1 Answers

Short grep solution:

grep -r --exclude="bower.json" --exclude-dir="results" "searchText"
like image 198
RomanPerekhrest Avatar answered Sep 18 '22 00:09

RomanPerekhrest