参见英文答案 >
cat multiple files but include filename as headers14个答案在猫的内容之前,找不到打印每个文件名的方法。这里是我想做的:
raja@badfox:~/Perl/t$ ls 1.txt 2.txt 3.txt raja@badfox:~/Perl/t$ echo " I am " >> 1.txt raja@badfox:~/Perl/t$ echo " trying " >> 2.txt raja@badfox:~/Perl/t$ echo " to do this " >> 3.txt raja@badfox:~/Perl/t$ cat *.* I am trying to do this raja@badfox:~/Perl/t$
在最后一个命令中,我只得到这些文件中的文本,但我实际上希望文本与文件名一起。我的意思就是这样
Filename:1.txt <Data in the file> Filename:2.txt <Data in that file> Filename:3.txt <Data in that file >