Unix Patch Tutorial
UNIX is a computer programming system used by companies to read files and directories from a database, which is where most companies store all raw data. One of the most useful commands within UNIX is the patch command. The patch command reads a source file's instructions on how to change a file and then applies those changes. The source file contains difference listings formed from the diff command. Diff is the result from comparing two files, and it builds instructions on how to reconcile the differences. The patch command will automatically use the source file to read from the standard input.
Instructions
-
-
1
Open UNIX. Type your username. Press "Enter." Type your password. Press "Enter."
-
2
Type
$ Diff oldFile newFile directory #-u
Press "Enter." This instructs diff to output the changes you will make to the old file to the new file, thus creating your patch file. The dollar sign appears automatically after you enter your login information. Every time you press "Enter" the dollar sign will appear at the beginning of each line.
-
-
3
Type
$ patch -i difflisting directory
Press "Enter." This instructs patch to apply the changes to the specified file(s) described in the directory. Patch automatically detects when the line numbers mentioned in the patch are incorrect or don't match your existing file, and it attempts to find the correct place to apply each hunk of the patch.
-
4
Type
$ patch -b -i difflisting directory
Press "Enter." By default, if you don't instruct UNIX how to save your patch file, the patch file will replace your original file. When you type "-b" in the save command procedure, you are instructing UNIX to create a backup. The original file will then be saved with an .orig extension.
-
1
Tips & Warnings
To get UNIX to define every syllable and abbreviation you are allowed to use in a patch command, type
$ man patch
Press "Enter."