的一个或多个文件列表内容与表示的文件名一个头 [英] List content of one or more files with a header showing the file name

查看:117
本文介绍了的一个或多个文件列表内容与表示的文件名一个头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时前,我读到一个博客,显示一个命令行命令的的滥用的给定文件的列表时,连续显示每个文件的内容和每个文件有显示文件的文件名头行在其下方。可能有人刷新我的记忆中?

Sometime ago I read a blog that showed a misuse of a commandline command that when given a list of files serially showed the content of each file and each file had header line showing the filename of the file below it. Could someone refresh my memory?

推荐答案

您可以使用为此:当给定多个文件,这两个工具precede每个文件的包含文件名的头内容

You can use either tail or head for this: when given multiple files, both tools precede each file's contents with a header containing the file name.

$ for i in {1..3}; do echo line$i > file$i; done
$ tail file*
==> file1 <==
line1

==> file2 <==
line2

==> file3 <==
line3

要输出整个文件,而不是刚刚过去/前10行,每行,请使用尾-n +1 头-n - 0

To output the entire files instead of just the last/first 10 lines of each, use tail -n +1 or head -n -0.

这篇关于的一个或多个文件列表内容与表示的文件名一个头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆