-5

I have file2 and file1. I want to append file2 to file1 but without changing file1. I want to put the output in anew file file3.

If I used cat file2 >> file1 this changes the content of file1.

  • 4
    Err... so cat file1 file2 > file3 then? – steeldriver Aug 1 '18 at 4:50
  • If I want file2 content at the end, then cat file2 file1 not cat file1 file2 as you mentioned or am I wrong? – user9371654 Aug 1 '18 at 5:02
  • you are wrong, and please before asking a question or add comment test your consideration or other one suggestions. please let me know what did happen with file2 >> file1 and what was your result of @steeldriver suggest? – Hossein Vatani Aug 1 '18 at 5:43
3

If you want to create a new file3 or file3 is empty.

cat file1 file2 > file3

If you want to append to file3.

cat file1 file2 >> file3

None of the above will modify file1 nor file2.

  • 1
    Thanks. Please correct the file names in the second command. You use file2 twice. – user9371654 Aug 1 '18 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.