此命令显示文件的第二行:
cat myfile | head -2 | tail -1
我的文件包含以下数据:
hello
mark
this is the head line
this is the first line
this is the second line
this is the last line
上面的命令将数据打印为: mark
但我无法理解这一点,因为 head -2 用于打印前两行,tail -1 打印最后一行,但是第二行是如何打印的!!!???
原文由 Rebooting 发布,翻译遵循 CC BY-SA 4.0 许可协议
tail 显示头输出的最后一行,头输出的最后一行是文件的第二行。
头部输出(输入到尾部):
尾部输出: