I've historically performed something like:
find . 2>/dev/null | xargs grep -i something_to_find 2>/dev/null
pwd is barfoo (
/foo/bar/baz/foofoo/foobar/foobaz/barfoo) it finds matches. However, if I
/foo, it no longer finds the matches.
- permissions are all 775
- the directories are not symbolic links
- they are all on the same file system / server
So I'm curious if there is a default
-maxdepth that is applied to find, or are there other constraints as to why this would not work?
Some great comments have been posted. Here is some additional info:
- this is for GNU, not POSIX
find --version: GNU find version 4.2.27
grep --version: (GNU grep) 2.5.1
xargs --version: GNU xargs version 4.2.27
- removing the redirection of STDERR has no bearing on the result, or lack thereof
- the path to the files in
barfoo(known to work) do not have spaces, however files in other directories in
/foo/barmay have spaces; though, I don't see how that would be problematic
- I realize I wasn't specific on the path, but these are all well-named directories, not to be confused with any devices
The first doesn't work, but the second does:
find . -type f | xargs grep -i something_to_find
find . -type f -name "*.ext" | xargs grep -i something_to_find
Even odder is that
-name "*.*" does not work, the file extension has to be given; which could be problematic when searching for something.
I'm wondering if there is termination after a max error count, or maximum buffer size. I know there are a lot of files in these directories, but the fact it works when specifying the filetype (limiting results) is interesting.