How to copy files from one file to another file that has contents I want to keep? In other words, I want the contents of file1 to go in file2 but the info in file1 to be added to the existing stuff in file2 ? The format in file2 should ideally have file2 info first then file1. Then I want to add file3 to file2 with the contents in file2 resulting in an output format of 1. File2 contents then 2. File1 contents and lastly file3 contents. All the files are in different directories. I would think a simple cp file1 file2 or cat file1 >> file2 would work but for some odd reason when I view file2 afterwards it only shows file1 info. Thank you in advance.

2 Answers 2


I think what you are lookig for is to append which is done using >> symbol:

Let say you have file1 with the content I'm file1 and file2 with the content I'm file2

Then you can do:

cat file1  >> file2   

This appends content of file1 to the end of file2.

now the result of file2` will be:

I'm file2
I'm file1

You can repeat the same command to add more as many more files as you like to the bottom of a file.


Let us say that you have file1, file2, file3 ... Then I suggest that you

  • either create a target file. Then the command

    cat file* > target
  • or have a target file and want to append to it. Then the command

    cat file* >> target

will do what you want.

  • Thank you both! I will try that !
    – Elon_s_mom
    Jun 7, 2021 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .