学习 grep 命令并遇到了这个。它如何与 tail 结合使用?

Learning the grep command and came across this. How does it work combined with tail?

什么会 grep '&' input.txt | tail -4给我?我是新手,不知道同时使用 grep 和 tail 会发生什么。

tail -4 对文件执行时通常会打印文件的最后四行

与:

grep '&' input.txt | tail -4

正在对 grep 命令的输出执行 tail 命令,因此将打印 grep 输出的最后 4 行。

例如,如果 input.txt 中出现 50 次“&”,则只会打印最后 4 次。