Grep multiple strings in same file

Find multiple strings in the same file using grep. Pass the results of grep to xargs with grep.

Find files containing both the add() method and the create() method.

$ grep -r -l "def add(" . | xargs grep -l "def create("

Edit the resulting files by enclosing the grep command in $().

$ vim $(grep -r -l "def add(" . | xargs grep -l "def create(")
View this page on GitHub.
Posted .


Leave a Reply