Monday, November 2, 2009

merge two files

To convenient merge two files use the diff utility with the -D option.
The command will be like:
diff -D _NEWFILE_ old_file.ext new_file.ext >result_file_to_edit.ext


With that -D option the result file will contain the C-preprocessor code, like

#ifdef _NEWFILE_
content only the new_file.ext
#endif /* _NEWFILE_ */

#ifndef _NEWFILE_
content only the old_file.ext
#endif /* _NEWFILE_ */

or

#ifndef _NEWFILE_
content only the old_file.ext
#else /* _NEWFILE_ */
content only the new_file.ext
#endif /* _NEWFILE_ */

Then use a text editor to manually search for the _NEWFILE_ string and modify the text
as you think it should be.

No comments:

Post a Comment