Skip to content

Instantly share code, notes, and snippets.

@HelioCampos
Last active April 1, 2016 19:40
Show Gist options
  • Save HelioCampos/0b328105fc01841e39d12fb52f0060f8 to your computer and use it in GitHub Desktop.
Save HelioCampos/0b328105fc01841e39d12fb52f0060f8 to your computer and use it in GitHub Desktop.
Generare or apply patches
#!/bin/bash
if [ #$ -ne 3 ]; then
echo "You need to pass, respectively, the operation (patch|apply), the old and the new versions of the file."
exit
fi
OPERATION=$1
OLD=$2
NEW=$3
if [ $OPERATION -eq 'patch' ]; then
diff -u $OLD $NEW > patch.patch
else
if [ $OPERATION -eq 'apply' ]; then
patch -b < patch.patch
else
echo "Error: Operation ($OPERATION) not recognized"
exit
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment