Friday, October 19, 2018

linux - How do I grep recursively?



How do I recursively grep all directories and subdirectories?



find . | xargs grep "texthere" *

Answer



grep -r "texthere" .



The first parameter represents the regular expression to search for, while the second one represents the directory that should be searched. In this case, . means the current directory.



Note: This works for GNU grep, and on some platforms like Solaris you must specifically use GNU grep as opposed to legacy implementation. For Solaris this is the ggrep command.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...