开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜