[root@localhost tmp]# more 2.txt
node
nodes
如果直接用grep命令,不加任何参数,会把所有匹配的行都检索出来,可以说是模糊匹配:
[root@localhost tmp]# more 2.txt |grep node
node
nodes
如果grep加了 -w参数,就会实现精准匹配,多了字符的行就不会被查询出来;
[root@localhost tmp]# more 2.txt |grep -w node
node
但是,当某种情况,如需要匹配的字符串是唯一的的时候,模糊匹配就等于精准匹配:
[root@localhost tmp]# more 2.txt |grep nodes
nodes
[root@localhost tmp]# more 2.txt |grep -w nodes
nodes