我正在 grep 本地 svn 目录。当我跑步时grep -r "pattern" .
我收到一些错误,例如
grep: ./Data/test: 没有这样的文件或目录
谁问的grep
寻找不存在的文件?
>grep --version
grep (GNU grep) 2.10
>lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
默认情况下,grep 不会忽略不存在或不可读的文件。您需要提供-s
or --no-messages
选项以便这样做。引用自man grep
:
-s, --no-messages
Suppress error messages about nonexistent or unreadable files.
Portability note: unlike GNU grep, 7th Edition Unix grep did not
conform to POSIX, because it lacked -q and its -s option behaved
like GNU grep's -q option. USG-style grep also lacked -q but
its -s option behaved like GNU grep. Portable shell scripts
should avoid both -q and -s and should redirect standard and
error output to /dev/null instead. (-s is specified by POSIX.)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)