Using diff to create batch files and subsequently running them against select files is such a convenient way to update, fix or change existing files, but many developers and system administrators simply don’t know much about them.
Here is a quick primer on using diff and apply changes for select files. Use diff –help to check out more options and flags.
NOTE: pay caution when using patching, any mistake or error are executed without warning or undo feature. It’s best to always make a backup of any file or folder that are going to be affected by your patch.
diff
Some useful flags you can specify when comparing files are -b (ignore white space difference), -B (ignore blanc lines), -r (recursive) and -i (ignore case).
Let’s say we need to change the GA analytics code on our pages and that they are unfortunately hard coded. The files are shown below as are the results from diff: Read more »




