Why does this command
find /etc -exec grep student {} \; 2>/dev/null
show me more results
than this command
grep -r student /etc 2>/dev/null
Answer
Probably there are some symbolic links under your /etc
. It looks like your grep -r
doesn't follow them but find
does.
Try grep -R
.
Note: neither -r
nor -R
is required by POSIX. Some implementations of grep
may not support them; some may support one of them, not necessarily following (or not) symbolic links like in this example; some may treat -R
and -r
alike. Refer to man 1 grep
in your OS to be sure.
No comments:
Post a Comment