Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
执行时,
$ls -1rt /目录 | 头 -n 3 文件1.txt 文件2.txt 文件3.txt
$ls -1rt /目录 | 尾 -n 3 文件 2.txt 文件 3.txt
谁能告诉我文件列表期间尾部和头部如何在内部工作以及为什么文件数量有这种差异?
提前致谢
head列出文件的一定数量的行。它不会完整地阅读它,只是前几行。tail做完全相同的事情,但从文件末尾开始。此处的-n 3参数是在 3 行后停止读取,然后仅打印它们。
head
tail
-n 3