Skip to content

Instantly share code, notes, and snippets.

@Evgenyoliver
Created March 15, 2016 13:51
Show Gist options
  • Save Evgenyoliver/3b9ba51a4f34aa440ab2 to your computer and use it in GitHub Desktop.
Save Evgenyoliver/3b9ba51a4f34aa440ab2 to your computer and use it in GitHub Desktop.
Linux patch file example
#!/bin/bash
mkdir modules
cat > modules/f1 << EOM
String 1
String for replace
EOM
cat > modules/f2 << EOM
String 1
String replaced
EOM
# diff -Naur f1 f2
# cat << EOF | patch -p0
# --- f1
# +++ f1
# @@ -1,2 +1,2 @@
# String 1
# -String for replace
# +String replaced
# EOF
# diff -Naur modules/f1 modules/f2
cat << EOF | patch -p1
--- old/modules/f1
+++ new/modules/f1
@@ -1,2 +1,2 @@
String 1
-String for replace
+String replaced
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment