List content of one or more files with a header showing the file name
问题 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? 回答1: 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