Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使使用了w标志,fgrep也不匹配整行_Grep - Fatal编程技术网

即使使用了w标志,fgrep也不匹配整行

即使使用了w标志,fgrep也不匹配整行,grep,Grep,我有两个文件,内容如下: 文件a hello hello-world hell 文件b hello-world hello 我想使用fgrep执行文件匹配,所以我使用这个命令 fgrep-wf a b 我希望它能完全像这样匹配两行 你好 你好,世界 但是它只匹配hello world的部分,即 你好 你好-世界 有人能告诉我为什么我不能匹配整个hello world行,即使它在两个文件中都有?破折号可能算作分词,所以hello匹配。但是我如何将它包括在搜索中?为什么哪个字符串匹配重要,只要它

我有两个文件,内容如下:

文件
a

hello
hello-world
hell
文件
b

hello-world
hello
我想使用
fgrep
执行文件匹配,所以我使用这个命令

fgrep-wf a b

我希望它能完全像这样匹配两行

你好

你好,世界

但是它只匹配
hello world
部分,即

你好

你好-世界


有人能告诉我为什么我不能匹配整个
hello world
行,即使它在两个文件中都有?

破折号可能算作分词,所以hello匹配。但是我如何将它包括在搜索中?为什么哪个字符串匹配重要,只要它匹配就行?您使用的是fgrep的别名,您是不是:
alias fgrep='fgrep--color=auto'
交换文件
a
的前两行,然后重新执行您的命令。