Diff
Jump to navigation
Jump to search
Using Diff
Using Diff to Determine changes when you have two files
Let's say you need to know the differences between a new patch file and your existing file.
Here is the command:
diff --unified --recursive --new-file firstfile secondfile > differencesfile or diff -urn first second differences
- Example:
diff -urn /usr/var/palm/somefile.pl /usr/home/mine/somenewfile.pl > /usr/var/mine/differences.txt
Using Diff to Patch An Existing File
Let's say you have downloaded a patch file for your Pre and you want to apply them. Here is the procedure
- Make a backup of the file to your own folder on the pre
- Take the file you need to apply (the patch) and place it onto the pre (more detail needed here)---- I'll add later
- Now you can change the production copy
Apply a Patch
A destination file is the file you will be overwriting/ patching into. The patch is the file that contains the changes and is in your /usr/home folder.
To apply a patch to a single file,
- Make the file system read-write instead of read-only, then
- Use WinSCP to transfer the patch to your Pre, put it in the /usr/home or some similar folder (I use /usr/home/FreeTim/somepatch )
- Change to the directory where the DESTINATION system file is located using cd command
- Make a backup copy of the file somewhere safe (I copy it to my home directory) using cp command then finally,
- call patch command:
The command is
patch --strip=1 --remove-empty-files < /usr/home/somepatchfile.pl || echo "failures!"
In this example, change the /usr/home/somepatchfile.pl to the folder of the file you have on the Pre you want to apply as a patch.
If this works (nothing is returned) then you can check for differences after the patch, if you like. But if nothing is returned, then it worked.
To apply a patch to a single file, change to the directory where the file is located and call patch:
cd /usr/var/palm/something patch --strip=1 --remove-empty-files < /usr/home/somepatchfile.pl || echo "failures!"
- No response indicates success
Check for Differences after the Patch
Let's say you want to just make sure the patch took effect.
Here is an example command.
diff --unified --recursive --new-file newfile existingfile
- If there is no diff between "newfile" and "existingfile", you'll just be put back at your command prompt, showing that there are no differences - success!
- Otherwise differences will be displayed.
If Differences Exist
Your choices here are
- Use 'vi' and other commands to fix the files or
- Just copy your (previously saved) original back into place.
This Wiki page
This document is a rough initial draft-- FreeTim3
References
- 10-Minute Guide to Patch (external link) http://stephenjungels.com/jungels.net/articles/diff-patch-ten-minutes.html
.