include argument to grep

Can someone explain why I'm getting the following output when I make this call to grep ?

dbliss@nx5[~]> grep -rnwl --include=ardid.sh.e* . -e "pkg_resources"
grep: ./.pulse/a319a33547084e303e0286aa00000023-runtime: Permission denied
grep: ./.pulse/2d3380c658b942aac267d6570000001f-runtime: Permission denied
grep: ./.pulse/d1aa29d3e0e227d33d032c9f00000020-runtime: Permission denied
grep: ./.pulse/e7a8f36648b96d90ecbddd2f00000018-runtime: Permission denied
grep: ./.pulse/922bdeb7e34db855d003e2fd00000019-runtime: Permission denied
grep: ./.pulse/2e970606c3a2bfa06aa690e600000018-runtime: Permission denied
grep: ./.pulse/c113767245ecdc7cb59125af00000017-runtime: Permission denied
grep: ./.pulse/0202df89e10e160883b6aa8200000021-runtime: Permission denied

I'm attempting to limit the search to files that match the pattern ardid.sh.e* -- ie, start with ardid.sh. , followed by any number of other characters. But the output shows that a bunch of files in the .pulse directory were searched that do not include ardid in their names.

If this is the wrong call to be making, what call should I be making?


Check that those are, in fact files, and not directories or symlinks.

grep might be attempting to access them to search for files that match your pattern and failing despite your --include argument.


Most likely that output is not part of the standard output grep produces, but of standard error output. grep has to access the file content to scan for the search pattern. For that it requires read permission to files and permission to enter directories. It posts that report per file or directory if it fails to gain access.

You can easily test that yourself if you simply drop the error output to get back only standard out:

grep -rnwl --include=ardid.sh.e* . -e "pkg_resources" 2 > /dev/null

Probably the output of that command will not show those entries any more...

链接地址: http://www.djcxy.com/p/78060.html

上一篇: grep命令删除所有dirs,而不仅仅是dirs匹配正则表达式?

下一篇: 包含grep的参数