当我使用命令时:
find . | xargs grep '...'
我得到了错误的匹配。我正在尝试在当前文件夹的所有文件中搜索字符串 ...
。
最佳答案
正如 Andy White 所说,您必须使用 fgrep
才能匹配纯 .
,或者转义点。
所以你必须写(-type f
是只有文件:你显然不想要目录。):
find . -type f | xargs fgrep '...'
或者如果你仍然想使用 grep :
find . -type f | xargs grep '\.\.\.'
如果你只想要当前目录而不是它的子目录:
find . -maxdepth 1 -type f | xargs fgrep '...'
关于regex - 使用grep搜索find : what is wrong with find .提供的文件 | xargs grep '...' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1204781/