在 linux 中打印文件的最后 2 行

Print the last 2nd line of a file in linux

如何在 Linux 中打印文本文件的最后 2 行,我可以使用 'sed -n 2p' 打印文件的第 2 行。我想以同样的方式打印最后 2 行。它是一个我们不知道计数的日志文件。 tail -n 1 将给出最后一行,但我只想打印最后 2 行。请推荐

怎么样tail -n 2 file.txt | head -1