Concatenate multiple files but include filename as section headers

前端 未结 20 1616
粉色の甜心
粉色の甜心 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:37

    First I created each file: echo 'information' > file1.txt for each file[123].txt.

    Then I printed each file to makes sure information was correct: tail file?.txt

    Then I did this: tail file?.txt >> Mainfile.txt. This created the Mainfile.txt to store the information in each file into a main file.

    cat Mainfile.txt confirmed it was okay.

    ==> file1.txt <== bluemoongoodbeer

    ==> file2.txt <== awesomepossum

    ==> file3.txt <== hownowbrowncow

    0 讨论(0)
  • 2020-12-12 09:41
    find . -type f -exec cat {} \; -print
    
    0 讨论(0)
提交回复
热议问题