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 file to precede the "data dump" for that file. Anyone know how to do this?
what I currently have:
file1.txt = bluemoongoodbeer file2.txt = awesomepossum file3.txt = hownowbrowncow cat file1.txt file2.txt file3.txt
desired output:
file1 bluemoongoodbeer file2 awesomepossum file3 hownowbrowncow
Was looking for the same thing, and found this to suggest:
tail -n +1 file1.txt file2.txt file3.txt
Output:
==> file1.txt <== <contents of file1.txt> ==> file2.txt <== <contents of file2.txt> ==> file3.txt <== <contents of 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With