Bash cat files in a directory into one file inserting filename before content
I have a directory of txt files to cat into another file. But I need to put a header before the content of each file. Specifically, I would like 开发者_StackOverflow社区to do something like this:
---------------- <FILENAME> ----------------
content
---------------- <FILENAME2> ---------------
content
Actually I don't need all the "------------" before and after the filename, but it would be nice.
Thank you for your time ;)
for f in *.txt; do echo "----------------<$f>----------------"; cat "$f"; done >> OUTPUT_FILE
精彩评论