简体   繁体   English

如何使用“tail -1 * / filename”拖尾多个文件的最后一行

[英]How to tail the last line of multiple files using “tail -1 */filename”

tail */filename

works, but 有效,但是

tail -1 */filename

doesn't. 没有。 Why is this? 为什么是这样? And is there a 1 liner to perform this task without loops? 是否有一个衬垫来执行此任务没有循环?

head -1 */filename

works for some strange reason. 适用于一些奇怪的原因。

While head works with -1 on multiple files, tail does not. 虽然head在多个文件上使用-1 ,但tail不能。 But it works with the -n argument instead: 但它适用于-n参数:

tail -n 1 */filename

If you are still looking for answer please try below one : 如果您仍在寻找答案,请尝试以下一项:

Go to the directory in which file are available and execute below command 转到文件可用的目录并执行以下命令

ls -1|while read file; do tail -1 $file; done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM