diff -u working/slang.c latest/slang.c > slang. To use this makefile, simply cd to the directory and type makepp. It’s the same command as above, with the output from diff redirected into a file called slang.patch.
To capture those differences in a patch file, use the following command. Seeing this type of output from diff confirms that there are differences between the two file versions and that the original file needs patching. If the files were identical, there would be no output listed at all. This is the command we issue to diff: diff -u working/slang.c latest/slang.cĭiff produces an output listing showing the differences between the files. The original file is listed first, then the modified file. We provide the names of the files so that diff knows which files to compare. The -u (unified) option tells diff to also list some of the un-modified text lines from before and after each of the changed sections. These lines are called context lines. They help the patch command locate precisely where a change must be made in the original file. We’ll compare the version in the working directory to the one in the latest directory. Select this type of project if you have a code base that has its own makefile but you wish to build the project through a GUI interface. Its default action is to list the modified lines in the terminal window. The diff command finds the differences between two files. Finding the Differences Between Two Versions of a File To be safe, the working directory is a copy of the current version of the text files. The latest directory holds the most recent version of those source code files, some of which have been modified. The working directory holds a set of source code files. One is called working, and the other one is called latest.
In this scenario, we are in a directory called work which contains two other directories. If not specified by the user, make will default to reading the file Makefile.
RELATED: How to Compare Two Text Files in the Linux Terminal Our Example Scenario Make, when invoked from the command line, reads a makefile for its configuration.
The patch command is most often used by people working with software source code files, but it works equally well with any set of text files whatever their purpose, source code or not. It is a special file that contains the shell commands that we create to maintain the project. We’ll walk you through it in this article. The make command invokes the execution of the makefile. What do you do with the patch file to actually patch your files? Apart from almost being a tongue-twister, that’s also a good question.