user2005383
user2005383

Reputation: 41

How can I search multiple files for a single word or phrase using grep and strings?

Im trying to look for a word like "numbers" in multiple files not just txt files using terminal. I have tried strings -r /media/E016-5484/* | grep numbers But it still doesn't work !

Upvotes: 0

Views: 5806

Answers (2)

Rialgar
Rialgar

Reputation: 753

If I am not mistaken, you are looking for grep numbers -r /media/E016-5484

From the manpage:

-r, --recursive

Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option.

Upvotes: 1

Puppet Master 3010
Puppet Master 3010

Reputation: 261

let say you are looking for 1234 in all files which in name contain file_pattern

 grep 1234 ` find . -name "*file_pattern*"`

or

 find  . -name "*file_pattern*" -exec grep 1234 {} \;

Upvotes: 4

Related Questions