How to append contents of multiple files into one file

前端 未结 11 2180
既然无缘
既然无缘 2020-12-22 15:49

I want to copy the contents of five files to one file as is. I tried doing it using cp for each file. But that overwrites the contents copied from the previous file. I also

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 16:35

    for i in {1..3}; do cat "$i.txt" >> 0.txt; done
    

    I found this page because I needed to join 952 files together into one. I found this to work much better if you have many files. This will do a loop for however many numbers you need and cat each one using >> to append onto the end of 0.txt.

提交回复
热议问题