Concatenate multiple files but include filename as section headers

前端 未结 20 1699
粉色の甜心
粉色の甜心 2020-12-12 09:08

I would like to concatenate a number of text files into one large file in terminal. I know I can do this using the cat command. However, I would like the filename of each fi

20条回答
  •  我在风中等你
    2020-12-12 09:34

    Was looking for the same thing, and found this to suggest:

    tail -n +1 file1.txt file2.txt file3.txt
    

    Output:

    ==> file1.txt <==
    
    
    ==> file2.txt <==
    
    
    ==> file3.txt <==
    
    

    If there is only a single file then the header will not be printed. If using GNU utils, you can use -v to always print a header.

提交回复
热议问题