Skip to content

Instantly share code, notes, and snippets.

@virullius
Created December 7, 2016 21:13
Show Gist options
  • Save virullius/78f8428db84181b155d343b06e20472c to your computer and use it in GitHub Desktop.
Save virullius/78f8428db84181b155d343b06e20472c to your computer and use it in GitHub Desktop.
#!/bin/bash
PATCH_ARGS=''
DELIMITER=__DIFF__
REALPATH=$(realpath $0)
DATA=$(tail -n +$(( $(grep -n $DELIMITER $REALPATH | tail -n 1 | cut -d : -f 1) + 1 )) $REALPATH)
printf '%s\n' "$DATA" | patch $PATCH_ARGS
exit 0
__DIFF__
--- one 2016-12-07 13:39:56.974517071 -0600
+++ two 2016-12-07 13:40:28.733159927 -0600
@@ -1,4 +1,5 @@
this is a file with content in it
line 2 was left blank
+line 4 is being added
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment