List content of one or more files with a header showing the file name

丶灬走出姿态 提交于 2019-12-02 10:54:22

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!