Low Orbit Flux Logo 2 F

Linux Command - patch

The Linux patch command can be used to apply a diff file ( patch ) to an original file.

Create a patch file:



diff -u hello.js hello2.js > my_fix.patch

Apply the patch ( from within the same directory ):



patch < my_fix.patch

Apply patch to specific file:



patch file_a.js < my_fix.patch

Patch specific file but write output to other specific file:



patch file_a.js -o file_b.js < my_fix.patch

Remove a patch ( apply the reverse of the patch ):



patch -R < my_fix.patch

Create a backup first:



patch -b < my_fix.patch