Create a patch file:
- Locate the file we want to change, eg.
path/file.json
- Create a copy of the file and edit it in the same directory, eg.
path/file.new.json
- Create the diff file by running the program diff, eg.
diff -u path/file.json path/file.new.json > file.json.diff
- Ensure or change the first lines of the diff file in order to point to the desired files, eg.
path/file.json
tobuild/path/file.json
- Apply the patch by running the program patch, eg.
patch -p0 < file.json.diff
Notes:
- Both programs, diff and patch, should be part of the core programs on any linux distribution
- The
-u
option specifies that the created file is of unified type - The
-p0
options specifies that the full paths inside the first lines of the diff file should be used
done_