Replace partial contents of file with contents read from other file

view full story

http://www.unix.com – Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to append the data. but i am seeing junk characters in between. request for help on this. Please find below sample File1.txt Code: Begin   End; after end1; after end2; File2.txt Code: Begin test1; test2; test3; end my output file should look like Code: Begin test1; test2; test3; end; (HowTos)