如何在另一个文件中突出显示一个文件中的单词? (Linux)

How to highlight words from one file in another file? (Linux)

host hostname {
        hardware ethernet 00:10:E0:dF:e2:Ee;
        fixed-address 192.168.*.*;
ddns-hostname name;
}

我在一个文件中有一个 IP 地址列表。我怎样才能突出显示 dhcpd.hosts 文件中的那些地址,并且仍然可以看到整个块或整个文本? 强调文字 我试过在读取变量时使用;做 grep $variable dhcpd.hosts;完成 < iplistfile

但它只打印一行

你可能想要

grep --color=always -f iplistfile dhcpd.hosts

您可能还想添加 -F-w 选项。