Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How do I grep recursively in Linux?

How do I recursively grep all directories and subdirectories?

find . | xargs grep "texthere" *
by

2 Answers

Kajalsi45d
Also:

find ./ -type f -print0 | xargs -0 grep "foo"

but grep -r is a better answer.
sandhya6gczb
For recursive search invoke grep with the -r option or --recursive. Here is an example to find pattern in a given directory.
$grep -r "pattern/directory_name"

Login / Signup to Answer the Question.