How to append one file to another in Linux from the shell?

后端 未结 8 1524
我寻月下人不归
我寻月下人不归 2020-12-04 04:44

I have two files: file1 and file2. How do I append the contents of file2 to file1 so that contents of file1

8条回答
  •  一整个雨季
    2020-12-04 05:36

    Another solution:

    cat file1 | tee -a file2
    

    tee has the benefit that you can append to as many files as you like, for example:

    cat file1 | tee -a file2 file3 file3
    

    will append the contents of file1 to file2, file3 and file4.

    From the man page:

    -a, --append
           append to the given FILEs, do not overwrite
    

提交回复
热议问题