Software > BSD, Linux, and Unix
How do I recursively grep all directories and subdirectories?
(1/1)
balasahu:
How do I recursively grep all directories and subdirectories?
--- Code: ---find . | xargs grep "texthere" *
--- End code ---
Thanks.
nil:
No need for xargs - you can use the grep -r option:
--- Code: ---me@nil:~/mydir$ find .
.
./dir4
./dir2
./dir2/file-b.txt
./dir2/dir3
./dir2/dir3/file.txt
me@nil:~/mydir$ grep -r Lorem .
./dir2/file-b.txt:Lorem ipsum dolor amet
./dir2/dir3/file.txt:Lorem ipsum
--- End code ---
If you want to follow symlinks, use -R instead.
Examples at Computer Hope - https://www.computerhope.com/unix/ugrep.htm#examples
Navigation
[0] Message Index
Go to full version